@lukegalea16 and once you log back in, does the session exists?
session('variable_name');
should not output anything if you've logged out. The session timeout is defined in your config/session.php file.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Once a user logs in, a session is created. When I add session data such as the below example, what will be the lifetime of that data? After logging out I opened the session file and found that the data remained there. If a session expires will it still be available? If it will still be available it will still be unusable however if the user is logged out right?
session()->put('variable_name',4);
Yes. When a session expires, due to inactivity, the related data will be considered expired too and deleted on the next garbage collection cycle.
On the file session driver, the session file will be "touched" (update) on every request. So its timestamp is always current.
If a user left their computer on and kept logged in into your app, after the session becomes expired due to its expiration time limit, on the next request Laravel will check the file timestamp and will generate a new session for that request, thus invalidating the current one.
Please or to participate in this conversation.