Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default cookie domain in Rails3

I want to set default cookie domain for my application to ".mydomain.com" to allow cookie session be preserved across subdomains. There are many places showing how to do it in Rails 2.x but these solutions doesn't work for Rails3. Anyone know how can I set it?

like image 985
sickill Avatar asked Apr 07 '10 13:04

sickill


1 Answers

I've found the solution. Here it is:

Rails.configuration.session_store :cookie_store, {
  :key    => '_your_app_session',
  :domain => ".domain.com"
}

This should go into config/initializers/session_store.rb. Works great for me.

like image 131
sickill Avatar answered Nov 09 '22 11:11

sickill