Accessing session data using session_id

Published on Author Akhil Bansal11 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]

11 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.

Leave a Reply to gauda Cancel reply

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