FOSUserBundle and remember me

╄→гoц情女王★ 提交于 2019-12-03 03:04:37

This was not working for me neither because i used 2 user providers: FOSUserBundle and FosFacebook.

The cookie was actually being set, but in TokenBasedRememberMeServices, processAutoLoginCookie i saw that the wrong provider was being used.

To fix it i had to specify in security.yml in remember_me section the provider i wanted to use.

firewalls:
    main:
        ...
        remember_me:
            secret:      "%secret%"
            lifetime: 2592000
            path:     /
            domain:   ~
            user_provider: fos_userbundle

Maybe this helps somebody else too.

Update: I've modified the response since in newer versions of Symfony, the "key" under remember_me is now called "secret".

As "Adrian C" said, but with a little change which worked for me.

instead "key" i used "secret"

 firewalls:
     main:
         ...
         remember_me:
             secret:      "%secret%"
             lifetime: 2592000
             path:     /
             domain:   ~
             user_provider: fos_userbundle

Remember me feature may not work if browser can't set cookies on your domain (localhost, for example). If this is a case, then setup your domain as a valid domain name (eg, dev.site.com). Also make sure you have cleared cache.

It's working for me with session lifetime in add of security remenber_me configuration:

  framework:
    session:
        default_locale: %locale%
        auto_start:     true
        lifetime:       3600
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!