Are your routes included in the web middleware? If not, the session will not start/work.
Try checking php artisan route:list to confirm
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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?*
It was a mistake in my code, not Laravel. Ignore.
Please or to participate in this conversation.