>
This took a little bit of poking around, so I decided to post it here.
Basically I was tracking down a bug, which resulted in a corrupt object (cart) in the web session. So I thought, it would be nice to play with this object in the console to see what’s up… But how do I get it in there?
There may be a more elegant way to do this but here is how I got it to load:
- Look in tmp/sessions and find the most recent file (ls -alrt on UNIX). Let’s say the file is called ‘tmp/sessions/ruby_sess.8eb9614a7e4e1e3b’
- Open console and type:
>> session = Marshal.load(File.open('tmp/sessions/ruby_sess.8eb9614a7e4e1e3b')) => {"hash"=>{:cart=... >> cart = session["hash"][:cart] ....In this case I was trying to access a cart object in the session, which was placed in the session with:
session[:cart] = Cart.new
That’s it!
Anonymous
September 9, 2008 at 1:29 pm
>What if you store the session in the DB?
Anonymous
December 16, 2008 at 7:31 am
>AR Session Store:Find the session id from the cookie and then Session.find_by_id(:my_session_id)
LemmingJoel
March 6, 2010 at 9:15 pm
>CGI::Session::ActiveRecordStore::Session.find_by_session_id(session_id)