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

anatrix's avatar

Laravel 4.2 Session Lifetime not working

Hi guys, been cursing at my computer for the last 8 hours trying to figure this one out.

Im on Laravel 4.2 and trying to get it so that my session expires and logs me out after 5 minutes. in my session.php file i did:

'lifetime' => 5,

'expire_on_close' => false,

Ill then leave my computer for like 15 minutes, come back, refresh, and im still logged in? I know when my session has expired because a modal appears asking for my login credentials, which usually appears when I've closed my laptop, left it a few hours, then come back to it.

Any thoughts?

Thanks in advance :)

0 likes
6 replies
anatrix's avatar

Thanks for the quick reply :)

Ive had a look through the link and was wondering if this can be dissected in anyway to work in 4.2? (It uses Middleware which i can only seem to find references to in the docs for 5.0 and above).

anatrix's avatar

Just given that a try and still no luck :/

shakti's avatar

can you show your session.php code so that we can analyse it

anatrix's avatar

did a full cmd+a, cmd+c, cmd+v on my session.php file and took out the comments:

return array(

'driver' => 'file',

'lifetime' => 5,

'expire_on_close' => false,

'files' => storage_path().'/sessions',

'connection' => null,

'table' => 'sessions',

'lottery' => array(2, 100),

'cookie' => 'laravel_session',

'path' => '/',

'domain' => null,

'secure' => false,

);

Please or to participate in this conversation.