Symfony sfGuardUser single authentication on several subdomains

爱⌒轻易说出口 提交于 2019-12-11 20:19:45

问题


I'm using symfony 1.4.20 with the sfGuardUser plugin. I have several subdomains that are sharing the same app.

One module of the app should serve a slightly different content according the user is logged in or not. This module should be accessed through a subdomain, say sub.domain.com. Right now, if I access this module through domain.com, this works. If I access the modules through sub.domain.com, the user is seen as not logged in even if he is.

My guess is the auth cookie used by the sfguad plugin is missing a Domain: .domain.com parameter. How can I change that? This thread 3207099 seems to indicate that it is possible.

Thanks!


回答1:


I found the solution. Add the session_cookie_domain parameter in the factories.yml file under /apps/my_app/config like:

  storage:
    class: sfSessionStorage
    param:
      session_name: symfony
      session_cookie_domain: '.domain.localhost'

I got confused because

  • I thought first that this was related to the auth cookie used by the sfGuard plugin but configuring the session cookie's Domain is enough to achieve what I want. Somebody can explain why?
  • I used a one-word-only domain for local tests and setting '.domain' does not end up in the cookie's Domain. Looks like it must be at least a domain and tld like '.domain.localhost'.


来源:https://stackoverflow.com/questions/19452914/symfony-sfguarduser-single-authentication-on-several-subdomains

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