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]
April 10, 2007 - 9:57 pm
This was the line a realy needed. Thanks so much.
May 10, 2007 - 4:58 pm
Great stuff. Many thanks!
September 11, 2007 - 1:48 pm
Thanks a lot mate
January 3, 2008 - 8:41 am
zVOoYG hi nice site thx http://peace.com
April 3, 2008 - 5:15 pm
thanks for sharing dude!
April 25, 2008 - 5:52 am
thanks for the great info
April 26, 2008 - 12:03 am
great rails
October 12, 2008 - 7:13 am
Thanks for sharing, i would not have enjoyed figuring this out myself.
February 23, 2009 - 4:10 am
Enjoyed the read, will bookmark.
June 16, 2009 - 8:47 am
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.