Symfony2:记住我令牌未设置 [英] Symfony2: remember me token is not set

查看:91
本文介绍了Symfony2:记住我令牌未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已根据需要进行了所有操作,但未设置记住我令牌。
我一直跟踪代码,直到
/vendor/symfony/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeService.php 中的位置为止 p>

I did everything as needed, yet my 'remember me' token is not set. I tracked the code until the part in /vendor/symfony/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeService.php where the cookie is set

$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部分如下所示:

When I do a dump of $response->headers, the cookies part looks like this:

["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数组第一个元素的键为空。

The cookies array first element's key is empty. Is that correct?

那是正确的,为什么没有设置cookie?

And if that's correct, why is the cookie not set?

编辑:
我的security.yml:

edit: My 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:   ~

如果您需要更多信息,请告诉我。

If you need any more information, let me know.

推荐答案

好,我已解决此问题。

原因与我的交互式登录监听器有关。
我听了成功的登录信息,但是在发送标头之前,我使用了一个新的RedirectResponse进行了重定向,该重定向当然不包括cookie。

The reason had to do with my interactiveloginlistener. I listened to succesful logins, yet before the headers were sent I redirected with a new RedirectResponse, which of course didn't include the cookies.

Phew。

这篇关于Symfony2:记住我令牌未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆