如何使用 Rails 2.3.8 在子域之间共享会话
我发现许多帖子描述了如何执行此操作。它们看起来都像是将其放入适当的环境配置文件中:
config.action_controller.session[:domain] = '.localhost'
但是,如果我这样做,则尝试登录(我正在使用设计)会失败:
ActionController::InvalidAuthenticityToken
我看到其他人发布了相同的问题(到各个博客的评论部分)提供设置 session[:domain] 的建议),但我还没有找到任何人回答了为什么会发生这种情况以及如何修复它的问题。
有什么想法吗?
I have found numerous posts that describe how to do this. They all look something like putting this in the appropriate environment config file:
config.action_controller.session[:domain] = '.localhost'
However, if I do this then trying to sign in (I am using devise) fails with:
ActionController::InvalidAuthenticityToken
I see others posting the same problem (to the comments section of the various blogs offering the advice to set session[:domain]) but I haven't found a case where anybody has answered the question about why that is happening and how to fix it.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定这是否与您的问题有关,但是您是否尝试将会话域设置为“.localhost”?这不会起作用,因为它实际上是您尝试为其设置 cookie 的顶级域。
请参阅http://www.ruby-forum.com/topic/181650#794923
I'm not sure if this is related to your problem, but are you trying to set the session domain to just '.localhost'? This won't work as it effectively a top-level domain that you are trying to set a cookie for.
See http://www.ruby-forum.com/topic/181650#794923
我在 config/initializers/set_session_domain.rb 中有这个片段:
一切都工作得很好。
I have this snippet in config/initializers/set_session_domain.rb:
Everything works pretty nice.