Archive for April 29th, 2009

Keeping session data across subdomains in Rails 2.3.2

Upgrading to Rails 2.3.2 I came across with the error of not keeping the session data between subdomains. That meant I had to authenticate each time I would change the subdomain.

The fix is simple.

Prior to version 2.3.2, I have had something like this in environments/development.rb file:

ActionController::Base.session_options[:session_domain] = '.w2task.local'

In Rails 2.3.2, I had to change this line into:

config.action_controller.session = { 
  :domain => ".w2task.local" 

Of course, same principle applies to development.rb, where:

config.action_controller.session = { 
  :domain => "" 

I’ve lost some hours in researching this solution, so I hope this will help others in need. too. As usual, I will be more than happy to hear comments from you.

Happy coding!