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

MrMoto9000's avatar

Session not persisting

UPDATE: It wasn't Laravel, it was my code. I WAS overwriting the value. Ignore the below.

*I understand that a request must fully complete for session data to be persisted, but I can't understand why one area of my app isn't doing that (while in others it's working fine).

There's POST request which is routed to a Controller, which (in turn) instantiates a Model and calls a method which runs the following:

session(['currentAttendance' => $id]);

After that completes successfully (which I can see in my debugging console), the controller runs:

return redirect()->route('profile');

But by the time the profile page appears, session('currentAttendance') is returning the previous value again.

Nothing is additionally changing the value, it just appears to not be persisting. There's no premature termination that I can see. No dd() etc.

Why isn't it working?*

0 likes
2 replies
Talinon's avatar

Are your routes included in the web middleware? If not, the session will not start/work.

Try checking php artisan route:list to confirm

MrMoto9000's avatar
MrMoto9000
OP
Best Answer
Level 7

It was a mistake in my code, not Laravel. Ignore.

Please or to participate in this conversation.