Accessing session data using session_id

Published on Author Akhil Bansal12 Comments

This is the very rare case but some times we need to access the data stored in session through session_id(specially when the request is not coming from browser). Here is a way I found and like to share:

[source:ruby] @user=CGI::Session::ActiveRecordStore::Session.find_by_session_id(@session_id).data[:user] [/source]

12 Responses to Accessing session data using session_id

  1. It’s good to receive the data from a specific session id, but in my case, the current session id keeps changing because there is no cookie enabled in my browser. The session database (I set the sessions to be stored in database) is full of useless sessions since the new request will receive a new session id. Is there a way to reuse the current session id in a new request without cookie? Thnx.

  2. Can anyone give example and explanation for this line. Actually I got session ID of web application from that how to get the session name or user ID. How to use the session variable, as i am getting error while using that as not defined

Leave a Reply

Your email address will not be published. Required fields are marked *