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

Stelikas's avatar

Laravel Auth Session logs me out after a period of time

Users in my application are getting logged out after a period of time although i have set the environment variable SESSION_LIFETIME = 525600

There are 100+ concurrent users in the application

The SESSION_DRIVER is set to file, i have read that changing to database and creating the php artisan session:table migration will make it work.

Shall i give it a try? Or is this based on another problem i might be having?

**Edit Locally this does not happen.

0 likes
8 replies
laracoft's avatar

@stelikas

How long is "after a period of time"? It might give some idea as to what is wrong.

Stelikas's avatar

There is not a standard time that logs me out.

laracoft's avatar

@stelikas

I would try setting SESSION_LIFETIME = 1 to see if changes any behavior. Are you using SESSION_DRIVER = file locally?

Stelikas's avatar

Locally using SESSION_LIFETIME = 1 logs me out after 1 minute, i have changed to database now, but i was using file.

laracoft's avatar

@stelikas

I have never used FILE before, but I suspect it is something else in your production and not DATABASE vs FILE. No harm trying though.

Stelikas's avatar

I'm using the standard Login Auth Route so i don't think the login function is the problem, also it's a single page application so it's also not a middleware problem which i might have not seen. It is weird that this happens in production but not locally. I read that using FILE in production is wrong, i will give DATABASE a try.

laracoft's avatar

@stelikas

Yea, file is not necessarily race safe, although I have not examined that part of Laravel's code before.

Stelikas's avatar
Stelikas
OP
Best Answer
Level 1

So changing the SESSION_DRIVER = database and using php artisan session:table fixed the issue and now everything works as expected.

Please or to participate in this conversation.