Sharing sessions across sub-domains

Posted by Jeff Kupperman Wed, 04 Apr 2007 20:34:21 GMT

Here's the answer (I think) to how we will share logins across each of the modules in the Trauma/Burn project:

This line goes in config/environments/ production.rb or development.rb:


ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update
( :session_domain => '.example.com')

Note the . before example.com , that is what makes the sessions work
between subdomains.

(Thanks to Ezra Zygmuntowicz's post on the rubyonrails list.)

When we go into production, we'll put each module on a different sub-domain, and then this should work ... as long as we're naming all our session variables the same way. Of course, we need to choose a domain name first....

Leave a comment, View comments, View trackbacks

Your Comments.

Leave your own response

  1. Roger replied: You could also run all the apps under one domain, as sub-directories. Mostly works out of the box if you use the helpers, although some plugins just assume application == root. (But you likely knew this. Posting anyway to distract myself from installing eDirectory for the 4th time...)
    Posted: 6 days later.
  2. Jeff commented: That's true. However, for the IPD projects there is a bigger problem -- what we really need is a single Users table related to all the apps. Ultimately, a couple of the best programmers are going through all the projects and merging them into one -- better them than me! I suppose the moral is, always name your models with a prefix that designates your project...
    Posted: 19 days later.

Spread the word.

Jeff Kupperman supports RSS (Real Simple Syndication), and Trackbacks from other blogs.

RSS feed for this post Trackback URI

Your Reply

Comment Form.

Fields denoted with a "*" are required.

You may also like to leave your email or website.