Get session with session_id in Ruby on Rails?

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

thank

+1


source to share


2 answers


If it is on a different domain (i.e. not a subdomain) there is no way to get session information (because it is stored in a cookie) - you will need something else (see this question ). If it's a subdomain I think there is a neat way to do it automatically by setting the cookie domain (look in environment.rb config.action_controller.session

, try setting :session_domain

)



+2


source


It looks like you could use something like:

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

      



However, I'm not sure if this is a good idea or not, in which case it is only useful if you are using ActiveRecordStore. Not sure what else is available in other stores, but if you target under actionpack / lib / action_controller / session / *, you will probably get a more definitive answer.

-1


source







All Articles