Rails 中的会话、子域和 authlogic 问题
我有一个带有 authlogic 身份验证的 Rails 应用程序和一个使用 subdomain-fu 构建的 username.domain.com 结构。
但是当从domain.com转到username.domain.com时,我的会话中断了。我尝试添加
config.action_controller.session = {:domain => '.localhost:3000'}
到我的development.rb中,但这似乎破坏了authlogic禁用注销/登录的功能。
关于该怎么做有什么建议吗?
提前致谢!
I've got a rails app with authlogic authentication and a username.domain.com structure built with subdomain-fu.
But my session breaks when going from domain.com to username.domain.com. I've tried to add
config.action_controller.session = {:domain => '.localhost:3000'}
to my development.rb but that seams to break authlogic disabling sign out/sign in.
Any suggestions on what to do?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在开发模式下遇到此问题,但在生产模式下可能不会出现此问题..您正在尝试设置顶级 cookie。您的浏览器不会让您这样做。您想要做的
就是
尝试创建自定义本地域,例如 localhost.localdomain 或 dummylocal.com 或其他东西,这将使其正常工作。
you are having this issue in the development mode but probably wont have this issue in prod mode.. you are trying to set the top level cookie. your browser wont let you do that. what you are trying to do with
is as good as saying
try creating custom local domain like localhost.localdomain or dummylocal.com or something and that will make it work.
对于 Rails3,上面的代码将引发
NoMethodError
:因此,对于 Rails3,您不应该更改环境配置,而应该将
app/config/initializers/session_store.rb
设置为如下所示:For Rails3 the code above will raise
NoMethodError
:So, for Rails3 you should not change you environment config but should set your
app/config/initializers/session_store.rb
to look like:也许这可以帮助:http://erikonrails.snowedin.net/?p=248 ?
Maybe this can help: http://erikonrails.snowedin.net/?p=248 ?