One Session, Many Apps

I'm looking for a way to share one ActiveRecordStore session between multiple apps. I'm sure its possible, but not sure how. Ideas?

Memcache. :slight_smile:

If you use Memcache to store your sessions, then you can easily access data across your applications. You just need to make sure you don't have namespace collisions or your data will get mixed up between the sites.

I know, not a very traditional solution to this problem, but for sites running on more than one server Memcache should be used anyway IMHO so you get the added benefit for free.

-- Mitch

Mitch Pirtle wrote:

Short answer, you can't :confused: Longer answer: It's easy enough to share the database sessions table but the cookies that store the session_id are tied to the domain they we're served from. So the only way to share the sessons out of the box is to use subdomains and set the session cookie correctly.

set the sessions cookie domain to .example.com the . is important

Then you can use the same sessions cookies across subdomains like foo.example.com bar.example.com

Cheers-

-- Ezra Zygmuntowicz-- Founder & Ruby Hacker
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)

Ezra Zygmuntowicz wrote:

The real answer to your question depends on what exactly you are
trying to accomplish. Sharing sessions might be the best, or even a
good solution. For example if your apps all require a login, just
create a separate table to hold the information you want to share and
key it off the username. Memcache would be perfect for this, not sure
why you are ruling it out.

If your apps all require a login, and the shared data absolutely has
to be saved on every request, then you can share sessions by creating
a username column in the sessions table, and modify activerecord so
when someone logs in it checks to see if a session exists for the
user, and if so resets the cookie session id to that user. That way
lies madness, but it can work in the right circumstances.

Chris