Problem with sessions, subdomains and authlogic in Rails

时间秒杀一切 提交于 2019-12-04 11:55:48

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

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.

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

For Rails3 the code above will raise 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:

YourAppName::Application.config.session_store :active_record_store,
    {:key => '_your_namespace_session', :domain => '.yourdomain.com'}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!