2016-01-12 70 views
0

我正在使用警卫进行用户验证,登录由html fetch api处理。Guard创建会话异步

如果登录成功,我得到js auth to api的令牌,但我想在页面更新用户登录后,但它不是。

作为回应,我看到为PHPSESSID和REMEMBERME设置cookie,但它看起来像这个cookie不会持久。

我不确定,哪里可以成为问题,看起来像守卫让他的工作很好。

请求不是跨域的。

请求报头:

GET /login/check-facebook?code=xxx HTTP/1.1 
Pragma: no-cache 
Cache-Control: no-cache 
accept: application/json 
content-type: application/json 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36 
x-api-token: anon. 
Accept-Encoding: gzip, deflate, sdch 
Accept-Language: en,cs;q=0.8,en-US;q=0.6 
DNT: 1 

响应头:

HTTP/1.1 200 OK 
Server: nginx/1.8.0 
Content-Type: application/json 
Transfer-Encoding: chunked 
Connection: keep-alive 
X-Powered-By: PHP/5.6.16 
Set-Cookie: PHPSESSID=xxx; path=/; HttpOnly 
Cache-Control: no-cache 
X-Debug-Token: edb1db 
X-Debug-Token-Link: /_profiler/edb1db 
Date: Tue, 12 Jan 2016 15:12:32 GMT 
Set-Cookie: REMEMBERME=xxx; expires=Tue, 19-Jan-2016 15:12:32 GMT; Max-Age=604800; path=/; httponly 

防火墙:

 main: 
     provider: db_provider 
     stateless: false 
     remember_me: 
      secret: "%secret%" 
      lifetime: 604800 # 1 week in seconds 
      path: /
      always_remember_me: true 
     pattern: ^/ 
     anonymous: ~ 
     logout: ~ 
     guard: 
      authenticators: 
       - authenticator.facebook 
       - authenticator.email 
      entry_point: authenticator.facebook 

回答

0

润版它。

在获取API选项credentials: 'same-origin'必须设置。

类似的事情必须用jquery或xhr发送。 withCredentials: true

+1

这不是“坚持cookie”,而是将其发回。 – zerkms