Sharing sessions across rails apps 2.3.2

I’ve done this in 2.2, but cannot figure it out for 2.3.2:

Basically, I want to be able to share session data across a couple of
apps.
The way I did this in 2.2 was to create a view called sessions in the
second app that read the sessions table of the first app.
This done, I could tell them both to use active record sessions, and,
lo! I had a shared session.
Once I’d written a little routine to swap between apps (to basically
clean out the session apart from user ids), I could then happily swap
back and forth between them.
The trouble is, rails has moved on to 2.3.2, and I’m having the very
devil of a time getting something like this working again.
I’m using the same view-as-sessions-table technique, and I have both
apps sessions set to the same key and secret in the initializers/
directory, but it just isn’t working.
Can anyone offer any advice as to what I could try next?
Cheers,
Doug.

On 13 May 2009, at 18:00, Doug L. wrote:

clean out the session apart from user ids), I could then happily swap
back and forth between them.

Don’t you need to be making the session cookie have a different domain
so that the cookie is sent to both apps ? I think some of the minutiae
of session options changed slightly with 2.3.2

Fred

That could well be part of it, but I’m afraid I’m not sure I follow you.
How would I go about doing that?
(I didn’t need to with my old approach.)
Cheers,
Doug.

On May 13, 7:56 pm, Doug L. [email protected]
wrote:

That could well be part of it, but I’m afraid I’m not sure I follow you.
How would I go about doing that?
(I didn’t need to with my old approach.)

Ah, we may not be talking about the same thing. Are these apps on
different subdomains (eg app1.example.com, app2.example.com),
different domains, or on the same domain (example.com/app1 &
example.com/app2) ?

Fred

They’re on the same machine, although I may want to move them at some
point.

On May 13, 8:56 pm, Doug L. [email protected]
wrote:

They’re on the same machine, although I may want to move them at some
point.

that doesn’t quite answer the question - even though they are on the
same machine any of the 3 scenarios I mentioned could be in effect.
What it boils down to in the end is cookies: there is a cookie that
tells rails which row from the sessions table to use and if both apps
aren’t getting the same value out of this cookie then although the
sessions are backed by the same table they will appear as different
users.

Fred

I had something very similar on one of my applications with 2.3.2 the
action_controller.session has changed and its now just :domain
and :key :

config.action_controller.session = {
:domain => ‘.me.com’,
:key => ‘_my_session’,
:secret => ‘long string’
}

This shares the me.com cookie with *.me.com so www.me.com or
secure.me.com or me.com

This goes in your environments/product.rb or development.rb files…

So if I have (locally) my apps all called things like “app1.local” and
“app2.local”, then I could set the domain to “.local”, which would
generate a “local” cookie that would be available to both apps, enabling
them to share a session?
Sorry if I’m labouring the point – I’ve had my head in this all day &
am correspondingly slow tonight!
& thankyou,
Doug.

Ah, I see, sorry – well, they’ll be on the same machine, but that is on
a local network (these are internal apps), and they are accessed by
names like “app1”, “app2”, with the local server’s DNS resolving them to
the server address, and passenger and phusion taking over from there.
That’s the idea, anyway – I had the proof-of-concept working, but
needed to upgrade the apps to 2.3.2 before deploying them.
You can probably tell this isn’t my area of expertise!
& thanks for your continued advice.
Doug.