Application managed session not propagating to subdomains

I am using Devise to manage authentication in a Rails 3.1 application. It works fine on my server. But I just created a new test server and if I log into the main site, subdomain access won't recognize the session. He asks me to log in again.

I cannot remember where I could eliminate this information. It seems to be a cookie setting.

I have domains pointing to each site, production and testing. Production ends in .net, test version ends in .co.

Can anyone point me in the right direction?


source to share

1 answer

I think this is not a setting, but a session and cookie setting.

You can work around this by setting a variable YourApp::Application.config.session

You can do this in your file environment.rb

or in config/initializers/session_store.rb

. Example for session_store.rb -

YourApp::Application.config.session = {
 :session_domain => '',
 :session_key => '_yourapp',
 :expire_after => 14*24*3600,
 #:secure => true, #for secure/ssl sessions and such
 :secret      => 'somesecretgobledygook' 


Please note that the option session_domain

set to

makes your cookies on different subdomains.

This applies to sessions. Similar settings for cookies.



All Articles