Losing session in rails 2.3.2 app using subdomain

前端 未结 10 1049
轻奢々
轻奢々 2020-12-06 13:39

I have a 2.2.3 app which I upgraded to 2.3.2

It\'s a multi-site (using subdomain) that creates one top level session for all sites.

This is how I change the

10条回答
  •  长情又很酷
    2020-12-06 14:27

    Olly's answer is correct, in rails 2.3 it should be:

    config.action_controller.session[:domain] = '.example.com'
    

    I just wanted to add that if you don't already have some session options created you may receive this when using that:

    undefined method `[]=' for nil:NilClass
    

    In that case you should use this instead (which creates the session variable instead of updating it):

    config.action_controller.session ||= {}
    config.action_controller.session[:domain] = '.example.com'
    

    Edit: apparently Rails 2.2.2 projects use something different. "domain" should be named "session_domain" and take the period character off the front of the domain. Try this:

    config.action_controller.session ||= {}
    config.action_controller.session[:session_domain] = 'example.com'
    

提交回复
热议问题