You may try in config/session.php*
'lifetime' => 120,
Reference: https://laravel.com/docs/5.3/session
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I want an user to logout when he is idle. I know this can be set in the config\session.php configuration. But when is a user actually idle? The site I am making is for an online game. When the user is playing the game, he doesn't navigate through the site itsels, so will the session be gone after x minutens (set in the config file) while playing the game or how does Laravel check whether the session is idle?
It checks the time of the session. Each session has a "time to life" based on your config in config/session.php. So when you refresh for example it checks if the session is still valid by checking the datetimestamp of the session with the current datetimestamp.
Now you say the user doesn't refresh the page at all, so what you can do is use the database session driver and check for yourself if the session is expired. You can then do that by polling with an ajax call for example and simply redirect the user to the logout page or something in that way.
Please or to participate in this conversation.