0

I'm front of some truble. I try to make the Devise Session cross domain.

First I set this line in session_store.rb

MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', domain: "myapp.fr"

But that did not work. Second, I put these lines in environments/.rb

Mtaville::Application.config.session_store :cookie_store, key: '_myapp_session', domain: "devloc.myapp.fr:3000"

What the problem?

EDIT 1

I have 5 subdomain : admin, auto, immo, resto, actu I have 6 types of user (depend of main class User) Administrator, Agent, Realtor, Restorer, Author, User

All this type of user can connect in front office (without subdoamin) BUT Administrator can only log in admin subdomain, restorer only in resto subdomain....

For each subdomain, I have a controller with :

before_filter :authenticated_administrator!

before_filter :authenticated_restorer!

...

Do you know how I can manage the session ?

Community
  • 1
  • 1
p0k3
  • 333
  • 5
  • 23

2 Answers2

2

Looks like you're trying to access across a subdomain. We had a similar problem, and solved it with this answer:

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

This should work for you if you're using a subdomain

Community
  • 1
  • 1
Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • Ok, I think it's a little bit more complicated... I'll explain it in the main question... – p0k3 Jun 02 '14 at 12:05
1

This previous answer should help you. When running into similar problems before, I've found the Rack::Cors gem to be incredibly helpful. I think that gem is mentioned on that other thread as well, so hopefully that will help.

Alex Lynham
  • 1,318
  • 2
  • 11
  • 29