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

stueynet's avatar

Session lifetime and expire_on_close

Ran into an interesting issue. My app requires a session idle time of 60 minutes. So in config/session.php:

    'lifetime' => 60,
    'expire_on_close' => false,

However I want to also make sure that the session expires when the browser is closed. Unfortunately if I do that then it ignores the lifetime:

    'lifetime' => 60,
    'expire_on_close' => true,

Anyone have a solution for this where we want a session lifetime AND also have it expire on close?

0 likes
3 replies
jlrdw's avatar

Is it working as expected, will it last 60 minutes and expire when browser is closed, which is what should happen. If a browser is closed you should want that session gone.

1 like
stueynet's avatar

Yeah but when you close the browser, the session is not gone. expire_on_close must be set to false in order for lifetime to work. Thus is doesn't lose the session when you close the browser. I believe its related to how the session stores in each case so wondering if anyone has a solution where you get the lifetime feature AND the expire on close feature.

jlrdw's avatar

If that is the case, go to the github site for laravel and post an issue, see if someone has already brought it up, it should destroy the session. Taylor needs to know about this.

2 likes

Please or to participate in this conversation.