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

jsouzasites's avatar

Login session expiring quickly

Guys, I have the following problem. My application's login sessions are configured to last 1 month, (SESSION_LIFETIME=43200), but at certain times if I spend a few minutes without browsing the site, I am automatically logged out. I'm using Redis. It was working fine before migrating from server a few months ago. Another observation is that it does not always happen and not with all users, one user reported that on the PC he is logged in normally, but on the cell phone he logs out in a few minutes. Suggestions of what to check?

0 likes
2 replies
TMcCann's avatar

Here are a few things to check. Without additional information this is tough to diagnose.

Verify that your session driver is set to Redis in your config/session.php file. If you're using a different session driver, it's possible that this could be causing the issue.

Check that your server time and time zone are set correctly. If the server time is incorrect, it can cause sessions to expire prematurely.

Check that your application is not being served from multiple sub-domains, which can cause cross-site cookie issues, leading to the session expiration.

1 like
jsouzasites's avatar

@TMcCann

I'm in Brazil, and it's now: Mon Mar 20 11:27:54 -03 2023

And on the server it is:

Mon Mar 20 14:26:00 UTC 2023

Can this difference cause this?

These are my settings I got from tinker config('session')

[ "driver" => "redis", "lifetime" => "43200", "expire_on_close" => false, "encrypt" => false, "files" => ".../storage/framework/sessions", "connection" => "session", "table" => "sessions", "store" => null, "lottery" => [ 2, 100, ], "cookie" => "name_session", "path" => "/", "domain" => null, "secure" => null, "http_only" => true, "same_site" => "lax", ]

Please or to participate in this conversation.