PanosJee
PanosJee

Reputation: 3866

Retrieve session with session_id in Ruby On Rails?

I want to access the session of a user from a different domain than the one that I initiated the session. Can I use session.session_id of the user and then retrieve the session hash of that user ?

Thank you

Upvotes: 1

Views: 2286

Answers (2)

sammich
sammich

Reputation: 335

It looks like you could use something like:

CGI::Session::ActiveRecordStore::SqlBypass::find_by_session_id(session_id)

However, I'm not sure if that's a good idea or not -- and in this case it is only useful if you're using the ActiveRecordStore. Not sure what else is available on the other stores, but if you poke around under actionpack/lib/action_controller/session/* you'll probably get a more definitive answer.

Upvotes: -1

zenazn
zenazn

Reputation: 14345

If it's on a different domain (i.e., not a subdomain), there's no way to get the session info (cause it's stored in a cookie)—you'll need something else (see this question). If it's a subdomain, I think there's a neat way to do it automatically by setting the cookie's domain (look in environment.rb's config.action_controller.session, try setting :session_domain)

Upvotes: 2

Related Questions