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

daniel21gt's avatar

Open session when closing browser, laravel 5.5

How are you

What can I do so that when I close the browser, the session is closed, since it is currently open.

I have changed 'expire_on_close' => false, in true but it is still the same

A case is normal to work well in firefox and not in opera and google chrome

0 likes
3 replies
Snapey's avatar

nothing is sent to the server when the user closes the browser.

The expires on close is a flag to tell the browser to discard the session cookie when the tab is closed.

The only way to do it is to use javascript to detect the browser window closing and send a message to the server.

.... but why???

daniel21gt's avatar

Well, sometimes there are careless people who close the browser and believe that their session too.

Snapey's avatar
Snapey
Best Answer
Level 122

so, with the expire_on_close set, the session is as good as closed as the browser will have discarded the session cookie. If you look on the server, the session file will still exist but noone can use it.

Please or to participate in this conversation.