Forum: Ruby on Rails session data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B6dd44a66d2a50a774dfd4454de9ccce?d=identicon&s=25 Dave Miles (gruntfuddler)
on 2007-03-07 00:30
I have a major headache.

I have a complete set of data from a database table and I have deleted
all of the contents from the table, DON'T ASK.

I need to recover the data.

The data is stored in the session hash and I have to retrieve it.

The problem is I cannot find a way to iterate through the session.
Trying "session.each do..." doesn't work, neither does "session.keys".

Any help out there for a DESPERATE final year student in a bit of a fix.

Humbly yours dave.
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-03-07 17:44
(Received via mailing list)
from the console

$ script/console

>> Marshal.load(Base64.decode64(ActiveRecord::Base.connection.select_one("select
* from sessions where session_id = '<your session id
here>'")["data"]))

it should return a hash of all the data stored in the session.

hope that helps
B6dd44a66d2a50a774dfd4454de9ccce?d=identicon&s=25 Dave Miles (gruntfuddler)
on 2007-03-09 00:26
Chris Hall wrote:

You're a superstar Chris. That pulled me out of hole.

But of course, that's what the session table holds! Don't know why I
didn't see it. Doh!

Many many thanks,
Dave
This topic is locked and can not be replied to.