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

arundev's avatar

Session is getting cleared

I have upgraded from 5.2 to laravel 8. I have a custom checkout and products are saved in a session key and value as an array, but this is getting cleared in between and not on a particular point, sometimes it is working and sometimes not. i have used session->save() in 5.2 this i have removed and also used ["middleware" =>"web"] for some of the routes but now i have removed this as well still it is not working properly, it is not breaking at one point so there is no sense in sharing my script also. Please help

0 likes
3 replies
jlrdw's avatar

If you just put anything in a session, like hi there.

Then load several of the pages at random.

Then try to Echo that session value out, does it persist.

That's been quite a few versions update I can't really recall if there was something involving sessions, but double check through the upgrade guides.

arundev's avatar

I have already tried as you said sometimes it is there and sometimes it not, my question is some of the request are From Requests $request instances, does it make any difference? And in some places i use session()->put, session()->get etc where we don't have $request, in latest versions this has changed? i couldn't find anything in doc. So my doubt is something like this, $request->session()->get('key') and session('key') these two only work? in laravel >5.2 and "session()->get('key')" do not work in laravel >5.2?

Snapey's avatar

I would install Laravel Debugbar then you can review whats in session at any point.

Please or to participate in this conversation.