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

ycsm's avatar
Level 1

Session data I've set disappears after a period of inactivity

Hi there. I may be doing this the wrong way, or there may be a better way to do it..

Upon login I'm setting some session data:

session(['api_token' => $user->api_token]);
session(['season' => Season::find($request->season)]);
session(['centres' => Centre::where('active', 1)->get()]);

I call it like so...

session('season')->name

.env file:

SESSION_LIFETIME=9999999999

This works great for a while, but if there's a period of a few hours of activity (I haven't timed it exactly), then the session data I've set gets lost, I have to log out then back in to set the session data again.

However, the user still remains logged in, I can pull Auth data perfectly fine.

What is going on here?

0 likes
1 reply
ycsm's avatar
Level 1

I think I may know the cause - I didn't change the env file on my public server... woops.

Please or to participate in this conversation.