Symfony2记住我只使用管理员角色

时间:2015-04-02 06:44:02

标签: php symfony authentication

我对symfony2的问题是记住我只与管理员用户合作,否则没有设置cookie。

当我在安全控制器中调用get('security.context') - > isGranted('IS_AUTHENTICATED_REMEMBERED'))时,它返回false

        main:
        remember_me:
            key:  "%secret%"
            lifetime: 31536000 
            path:    /
            domain:   ~                                 
        pattern: ^/
        form_login:
            remember_me: true
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
            default_target_path: /
            failure_path: /
            login_path: /
        logout:
            target: /
        anonymous:    true

1 个答案:

答案 0 :(得分:0)

  1. 检查配置
  2. 防火墙:

    main:
        remember_me:
            key:      "%secret%"
            lifetime: 31536000 # 365 days in seconds
            path:     /
            domain:   ~ # Defaults to the current domain from $_SERVER
            always_remember_me: true
        secured_area:
             pattern:    ^/
             anonymous: ~
             form_login:
                 login_path:  login
                 check_path:  login_check
                 remember_me: true 
             logout:
                 path:   /logout
                 target: /
    
    1. 清除缓存