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

coderic's avatar

Session expires but not logging user out in Laravel 5

I've gone in to the sessions file in the config folder and changed the lifetime = 1 and expire_on_close = false.

Anything that I put in to the session variable gets wiped out after x amount of minutes that I set in the config file but I'm still not logged out. Am I supposed to create something that logs me out or is Laravel supposed to log me out automatically?

0 likes
9 replies
sitesense's avatar

Did you choose "Remember Me" when you logged in?

If so you will be automatically logged in and may not realise that you were in fact logged out.

bashy's avatar

So things added with

Session::put('key', 'value');

session(['key' => 'value']);

and it gets removed after X seconds/minutes while you're still logged in?

sitesense's avatar
Level 19

@bashy from my understanding he has deliberately set the session timeout to 1 minute and can see that the session variables are "wiped" after that time period, but says he is still logged in - i.e. the session timeout doesn't appear to log him out.

If "remember me" is set though, when he refreshes the page it will appear as if he was never logged out.

bashy's avatar

@sitesense Does putting keys/values in the session abide by that expire time then?

coderic's avatar

@bashy Yeah. Stuff I put in Session myself expires after the 1 minute lifetime I set but I still don't get logged out. I explicitly set the remember parameter to false in login and I'm testing it right now.

coderic's avatar

@sitesense Your suggestion to check the remember me option helped! I had javascript code to pass in to the AuthController if the "remember me" option was checked but I guess it wasn't doing it's job and passing in true even if it wasn't checked. I'll troubleshoot that myself. Thanks for your contribution to the solution everyone!

bashy's avatar

Yeah guess it would be on that expire time although would of thought it went along with the remember token expire time if it's selected.

Please or to participate in this conversation.