Thursday, December 6, 2007

Getting session data in irb

The irb love continues.
This has been blogged before but it's just worthy of being repeated. I needed to check whether something had been stored into the session for the last (failed!) request. Easy. Check mysql for the last session record updated in the sessions table. Copy the session id. Pop open script/console and
session = CGI::Session::ActiveRecordStore::Session.find_by_session_id("8346c9dc0df")
where the session id is that mess at the end. Now:
>> session.data
=> {:user=>55, :user_login=>"JaneDoe", :skin=>"europe", :traveler_login=>"JaneDoe", "flash"=>{}, :traveler=>55}
>>
It's live so you can make changes on the fly.

No comments: