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

juan's avatar
Level 1

Session randomly expires

I have a question, why my session randomly expires when I set up the settings to expire in 1000 minutes? Any help on that? I have read somethign about session.gc_maxlifetime but not sure where to change those values in laravel.

This is my config.sessions

 'driver' => env('SESSION_DRIVER', 'file'),
 'lifetime' => 1000,
 'expire_on_close' => true,
 'encrypt' => false,
 'files' => storage_path('framework/sessions'),
 'connection' => null,
 'table' => 'sessions',
 'lottery' => [2, 100],
 'cookie' => 'laravel_session',
 'path' => '/',
 'domain' => null,
 'secure' => false,
0 likes
6 replies
tykus's avatar
tykus
Best Answer
Level 104

Laravel's session garbage collection will respect the session lifetime config that you set - it should not destroy session data unless it is older than the specified $lifetime

1 like
juan's avatar
Level 1

Ohhh thanks for clarify that for me.

Do you know why the session times out randomly tho?

tykus's avatar

Can you check if the laravel_session cookie expiry also?

juan's avatar
Level 1

there's no cookie in the browser under that name even though there's a new session created.

tykus's avatar

Really? Have you changed the Session Cookie Name in config/session.php?

juan's avatar
Level 1

no man. That's weird. I am using Chrome, and setting for it is set up to 'Allow local data to be set'. In config/session.php , the set up for it is

  'cookie' => 'laravel_session'

Please or to participate in this conversation.