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

tapas's avatar
Level 15

Authentication session not clearing on browser close (expire_on_close = true is not working)

I login to my app using Auth::loginUsingId($id)/Auth::attempt($data). But after I close the browser and open it again, I still see that I am logged in.

How can I fix that?

in session.php:

'lifetime' => 120, 'expire_on_close' => true,

and session driver is set to:

SESSION_DRIVER=file

0 likes
9 replies
Snapey's avatar

bear in mind that the expire on close is something that the browser has to honour - not the framework

tapas's avatar
Level 15

I tried on different browsers(Chrome, Firefox, Safari). but the result is same......

I am using Laravel 5.3....

don't understand what can I do.... :(

Snapey's avatar

Do you have remember token on your users table?

Snapey's avatar

so when you turn up you are not connected to the old session, a new one is started and you are logged in by having the same token as in the database.

run your check after clearing the remember token

tapas's avatar
Level 15

cleared the remember token, and checked again but same result......

jlrdw's avatar

Make sure all cache is cleared.

tapas's avatar
Level 15

not working, I installed new app and made authentication. that is also not working.........

Please or to participate in this conversation.