Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.2.8 - Share Devise Sessions Across Subdomains with POW

I am trying to set up a simple subdomain-based blog in rails 3.2.8. Basically it will have sites, users (authenticated through Devise), and memberships to connect users to sites. I set up POW so that myapp.dev is working properly. Each site has a subdomain and I can navigate to the site#show action using the subdomains with no problems. My issue is that I can't get the Devise sessions to be shared across subdomains. Everything is working fine on my heroku app, but I would like to be able to test this locally.

When I add the following to session_store.rb, teh sessions seem to work across subdomains, but then I can't log out.

Appname::Application.config.session_store :cookie_store, :key => '_appname_session', domain: :all

When I change the end to domain: ".appname.dev" it doesn't work.

Any help would be greatly appreciated!

like image 922
dvanderb Avatar asked Aug 23 '12 13:08

dvanderb


1 Answers

Make sure you clear your cookies and restart the app.

Appname::Application.config.session_store :cookie_store, :key => '_appname_session', domain: ".appname.dev"

domain: ".appname.dev" is the correct format for the domain option. The beginning period is important.

like image 131
excid3 Avatar answered Oct 25 '22 12:10

excid3