Symfony2 : remember me cookie gets deleted when reopening the browser

I recently had this problem, and here is the solution I found:php

The reason why the cookie is deleted is because the user information that the cookie contains doesn't match anything that Symfony knows about. It can't log a user in based on the cookie, so it just deletes it. The issue in my case was an incorrect string in my UserProvider class. The specific method is supportsClass. It was returning 'AppBundle\Security\User' when it should have actually been returning `'AppBundle\Entity\User'. This caused Symfony to be unable to find any users based on the information in the cookie, and then it would just delete the cookie and move on.cookie

You can do some more troubleshooting if you go into this file: vendor/symfony/symfony/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php. Play around in processAutoLoginCookie and see if you can't figure something out!ide

Good luck!this

相關文章
相關標籤/搜索