简体   繁体   中英

Can't keep user logged in after upgrading to Laravel 5.4

I had an application made with Laravel 5.3 that was running fine, but after upgrading to Laravel 5.4, every time we authenticate, it goes fine and we have access to user informations :

{"id":X,"name":"Foo","email":"foo@bar.com", . . .}

The thing is, it is not really logged in as when we want to access a protected view that this user would have access to, it redirects on the login page.
I checked a fresh install of Laravel 5.4 methods of authentication and can't find any difference between application and this fresh 5.4 application.
So if someone could tell me where this problem comes from, it would be really helpful,
Thanks.

EDIT : It seems that the Auth()->user() gets null value while in the middleware that protects the routes.

I found what went wrong, but didn't wrote the answer here.

What was actually happening is that it seemed that session cookies had the encrypt config option set to false, but it was needing the EncryptCookies middleware, which was missing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM