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

onmyown's avatar

Laravel 5.1 Configuration Session Lifetime Apply Changes

simple question here. In my laravel config/session.php I have changed the lifetime value from the default 2 hours to this:

 /*
    |--------------------------------------------------------------------------
    | Session Lifetime
    |--------------------------------------------------------------------------
    |
    | Here you may specify the number of minutes that you wish the session
    | to be allowed to remain idle before it expires. If you want them
    | to immediately expire on the browser closing, set that option.
    |
    */

    'lifetime' => 1440,

    'expire_on_close' => true,

    /*

However, even though this is what I have on my server, it still sticks to the default 2 hour session. I can verify this by seeing the cookie laravel_session which always maxes out in 2 hours.

What am I missing? Is there a separate configuration file or value I need to change to apply my new lifetime?

Edit: Well apparently you can't expect both the lifetime and the expire_on_close option to both be operating at the same time because they utilize two different types of cookies, but I still don't understand why if I have the expire_on_close set to true why my cookie is expiring in 2 hours rather than when the browsing session ends?

0 likes
3 replies
onmyown's avatar

Sorry but, (bump).

To be clear, I would like to have the settings right so that it terminates the session only when the browser closes.

onmyown's avatar
onmyown
OP
Best Answer
Level 1

php artisan config:cache applies changes to the configuration files!

Please or to participate in this conversation.