Rails中的会话,子域和身份验证问题 [英] Problem with sessions, subdomains and authlogic in Rails

查看:110
本文介绍了Rails中的会话,子域和身份验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有authlogic身份验证和使用subdomain-fu构建的username.domain.com结构的Rails应用程序.

I've got a rails app with authlogic authentication and a username.domain.com structure built with subdomain-fu.

但是从domain.com转到username.domain.com时,我的会话中断了.我尝试添加

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'}

到我的development.rb,但它的出现破坏了authlogic禁用注销/登录的能力.

to my development.rb but that seams to break authlogic disabling sign out/sign in.

关于做什么的任何建议?

Any suggestions on what to do?

提前谢谢!

推荐答案

您在开发模式下遇到此问题,但在prod模式下可能不会遇到此问题..您正在尝试设置顶级cookie.您的浏览器不会允许您这样做.

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

config.action_controller.session = {:domain => '.localhost:3000'}

和说的一样好

config.action_controller.session = {:domain => '.com'}

尝试创建自定义本地域,例如localhost.localdomain或dummylocal.com或类似的东西,它将使它正常工作.

try creating custom local domain like localhost.localdomain or dummylocal.com or something and that will make it work.

config.action_controller.session = {:domain => 'localhost.localdomain'}
config.action_controller.session = {:domain => 'dummylocal.com'}

这篇关于Rails中的会话,子域和身份验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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