Sharing a session between subdomains
http://guestbook.co.za/ is also available at http://www.guestbook.co.za/. We wanted our users to remain logged in if they’re using GuestBook without the ‘www.’ subdomain and then enter it or visit the site from a link.
To do so we needed to share the session between www.guestbook.co.za and guestbook.co.za. This sounds really difficult but thankfully all it takes is prepending the domain name of your cookie with a period (.)
Here’s how to do it in Rails:
1 2 3 4 5 6 |
# In your production.rb file config.action_controller.session = { :session_domain => ".your-domain.tld", :session_key => "_yourapp", :secret => "somehugesecretkeythathastobemorethanthirtycharacterslong" } |
Thanks for the original post I got this from!