Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sven0188's avatar

Laravel 5.4 & Laragon Session On Multiple Apps Messy

Good day Everyone,

I am battling a while with random session that logs out. My session interval is set at 600 in session.php.

But what I have noticed now recently. It seems like the sessions of different apps get mixed up. I am using Laragon 3.

Anyone here with good advise? Or on how to fix this please.

We are running one Windows Server with Laragon 3 and multiple Laravel apps on this instance. BTW: I have set a unique APP_NAME for each Laravel app in app.php as well.

0 likes
1 reply
leokhoa's avatar

@Sven0188 : There is an unstable issue with Laravel environments with Apache on Windows:

To clear things up; this is a known issue. It's just not documented.

You must run ´php artisan config:cache` in both Laravel projects to generate a cached configuration. This is a requirement for Apache on Windows (and many other setups).

Dotenv will set process-wide environment variables, and only if they don't already exists. This means that the first Laravel app is executed, sets the first environment variables, then it calls the same webserver (in your case) where the second Laravel app sees that the environment variables are already set, and wont set the correct ones.

This often shows up when you have an application calling an api at the same machine, or during load tests. You should be able to open two browsers, point them to /projectA and /projectB, and reproduce this by just refreshing the page. A sleep(...) helps to slow things down.

Also, env() never returns cached results. It returns the currently set environment variable. When you use php artisan config:cache dotenv isn't loaded (Laravel 5.2+) and the environment variables aren't set. That's why you should use config() instead.

https://github.com/laravel/framework/issues/19454

I think switching to Nginx should help.

1 like

Please or to participate in this conversation.