我做了所有需要的事情,但我的“记住我”令牌没有设置。我跟踪代码,直到 /vendor/symfony/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeService.php中设置 cookie的部分
$response->headers->setCookie(
new Cookie(
$this->options['name'],
$value,
$expires,
$this->options['path'],
$this->options['domain'],
$this->options['secure'],
$this->options['httponly']
)
);
当我转储 $response->headers 时,cookie 部分如下所示:
["cookies":protected]=> array(1) { [""]=> array(1) { ["/"]=> array(1) { ["REMEMBERME"]=> object(Symfony\Component\HttpFoundation\Cookie)#753 (7) { ["name":protected]=> string(10) "REMEMBERME" ["value":protected]=> string(176) "V2Vic3BpblxVc2VyQnVuZGxlXEVudGl0eVxVc2VyOmJXRmliMmRwWlVCbmJXRnBiQzVqYjIwPToxMzM5MjQ5Mjc5OmJjY2QxMWYxNGNkZmQxZmI5ZTNjOTBhYTBiMTEyNjEwYzdkMWYxOGYwYWQzMmMzYmJhYzZlODM3Yjc0Nzc3Mjk=" ["domain":protected]=> NULL ["expire":protected]=> int(1339249279) ["path":protected]=> string(1) "/" ["secure":protected]=> bool(false) ["httpOnly":protected]=> bool(true) } } } }
cookies 数组第一个元素的键为空。那是对的吗?
如果这是正确的,为什么没有设置 cookie?
编辑: 我的security.yml:
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
login_path: fos_user_security_login
check_path: fos_user_security_check
logout:
path: _security_logout
target: _welcome
anonymous: true
remember_me:
key: "%secret%"
lifetime: 36000
path: /
domain: ~
如果您需要更多信息,请告诉我。