0

I have a User, set up with Devise.

User can have his own page (with subdomain). Like: awesomeuser.domain.com

On localhost after sign in I can visit both root path and path with subdomain - and he's signed in.

But on production server when he visits path with subdomain - he gets signed out.

Does anyone know what it can be caused by?

Since it works on local machine - I know it's sessions, but what exactly?

Here's my config/initializers/session_store.rb:

MyApp::Application.config.session_store :cookie_store, key: '_MyApp_session', domain: :all
Serge Vinogradoff
  • 2,262
  • 4
  • 26
  • 42

1 Answers1

0

We had this problem - the issue is your session can only be passed between one domain. The solution is to use domain: :all, however, as you're using subdomain, you have to specify the level of domains the cookies will be valid for, hence tld_length: 2

MyApp::Application.config.session_store :cookie_store, key: '_MyApp_session', domain: :all, tld_length: 2 

We found the answer here: Share session (cookies) between subdomains in Rails?

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147