Rails 3 default cookie domain for subdomains
In Rails 3 the way you set your default cookie domain to allow your session to be shared across subdomains has changed. In Rails 2.3.5 you would add the following to your application.rb :
config.action_dispatch.session = {:domain =>".mydomain.com"}
In Rails 3 there is now a session_store.rb initialiser, in there you can configure your default domain like so:
Rails.application.config.session_store :cookie_store, :key => '_app_session', :domain => '.mydomain.com'
5 comments
Matthew Ford said...
@filippo are you placing this in the session store initializer, not in your environment files?
Matthew Ford said...
@ernest see http://github.com/rails/rails/blob/4e92134dfa15ae198c714b85376838ffec5a7773/r...The first argument needs to be the type of session store