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

RoboRobok's avatar

Session not working after moving from 5.2 to 5.3

I'm moving my app from Laravel 5.2 to 5.3. So far so good, except one thing. Auth::attempt($credentials) doesn't make my user logged in after redirection. It returns true and puts value with key, fox example, login_web_59ba36addc2b2f9401580f014c7f58ea4e30989d to session, but after redirection, this value is no longer present in session. The same goes with any session value, I'm losing it after redirection. I'm using database to store sessions and this table is not empty. I tried to change the session handler to file, but it doesn't work neither.

Any ideas why is it happening?

0 likes
2 replies
dmitov's avatar

Can you post your routes/web.php file and your app/Http/Kernel.php file?

RoboRobok's avatar
RoboRobok
OP
Best Answer
Level 7

I found the answer! I found out my sign in form works if I disable JavaScript, so I knew it's something with my api Kernel. I changed this:

'api'   => [
    'throttle:60,1',
    'bindings',
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    \App\Http\Middleware\ResponseToJson::class,
],

To this:

'api'   => [
    'throttle:60,1',
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    \App\Http\Middleware\ResponseToJson::class,
    'bindings',
],

And it worked. So I moved bindings middleware to the bottom and it works now. Not sure why though. Do you have an idea?

Please or to participate in this conversation.