Its all about Ruby On Rails
Accessing session data using session_id
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:
@user=CGI::Session::ActiveRecordStore::Session.find_by_session_id(@session_id).data[:user]
| Print article | This entry was posted by Akhil Bansal on December 8, 2006 at 12:07 am, and is filed under ROR, Rails, Rubyonrails, session. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 3 years ago
This was the line a realy needed. Thanks so much.
about 3 years ago
Great stuff. Many thanks!
about 2 years ago
Thanks a lot mate
about 2 years ago
zVOoYG hi nice site thx http://peace.com
about 2 years ago
thanks for sharing dude!
about 2 years ago
thanks for the great info
about 2 years ago
great rails
about 1 year ago
Thanks for sharing, i would not have enjoyed figuring this out myself.
about 1 year ago
Enjoyed the read, will bookmark.
about 1 year ago
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.