Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 Session across subdomains

I'm trying the following with no luck in an attempt to persist sessions across subdomains:

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => :all, :tld_length => 2

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => 'myapp.dev'

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => '.myapp.dev'

I found all of these combinations on Google and SO.

I saw a few explanations but it involved manually setting the cookie. I'd like to stick with configuration if possible.

Note: I'm using devise. I've also restarted the server and cleared cookies.

like image 837
orourkedd Avatar asked Jan 21 '14 15:01

orourkedd


1 Answers

I found that different applications should have identical secret_key_base, located in config/initializers/secret_token.rb. After I did this, all my applications is started to use shared session.

PS. Of course, they should have identical session keys.

like image 125
kuatro Avatar answered Oct 13 '22 01:10

kuatro