Rails中的会话,子域和authlogic问题

时间:2022-08-19 16:47:17

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

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

But my session breaks when going from domain.com to username.domain.com. I've tried to add

但是当我从domain.com转到username.domain.com时,我的会话中断了。我试过补充一下

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

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

到我的development.rb,但接缝打破authlogic禁用注销/登录。

Any suggestions on what to do?

关于该怎么做的任何建议?

Thanks in advance!

提前致谢!

3 个解决方案

#1


1  

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

您在开发模式中遇到此问题,但可能在prod模式下没有此问题..您正在尝试设置*cookie。你的浏览器不会让你这样做。你想要做什么

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

is as good as saying

就像说的一样好

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

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

尝试创建自定义本地域,如localhost.localdomain或dummylocal.com或其他东西,这将使其工作。

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

#2


1  

For Rails3 the code above will raise NoMethodError:

对于Rails3,上面的代码将引发NoMethodError:

undefined method `session=' for ActionController::Base:Class

So, for Rails3 you should not change you environment config but should set your app/config/initializers/session_store.rb to look like:

因此,对于Rails3,您不应该更改环境配置,但应将app / config / initializers / session_store.rb设置为:

YourAppName::Application.config.session_store :active_record_store,
    {:key => '_your_namespace_session', :domain => '.yourdomain.com'}

#3


0  

Maybe this can help: http://erikonrails.snowedin.net/?p=248 ?

也许这可以帮助:http://erikonrails.snowedin.net/?p = 248?

#1


1  

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

您在开发模式中遇到此问题,但可能在prod模式下没有此问题..您正在尝试设置*cookie。你的浏览器不会让你这样做。你想要做什么

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

is as good as saying

就像说的一样好

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

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

尝试创建自定义本地域,如localhost.localdomain或dummylocal.com或其他东西,这将使其工作。

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

#2


1  

For Rails3 the code above will raise NoMethodError:

对于Rails3,上面的代码将引发NoMethodError:

undefined method `session=' for ActionController::Base:Class

So, for Rails3 you should not change you environment config but should set your app/config/initializers/session_store.rb to look like:

因此,对于Rails3,您不应该更改环境配置,但应将app / config / initializers / session_store.rb设置为:

YourAppName::Application.config.session_store :active_record_store,
    {:key => '_your_namespace_session', :domain => '.yourdomain.com'}

#3


0  

Maybe this can help: http://erikonrails.snowedin.net/?p=248 ?

也许这可以帮助:http://erikonrails.snowedin.net/?p = 248?