# Session data

**URL:** <https://www.ruby-forum.com/t/session-data/87941>\
**Category:** Rails\
**Created:** [March 7, 2007, 12:30am UTC](https://www.ruby-forum.com/t/session-data/87941 "2007-03-07T00:30:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [March 7, 2007, 12:30am UTC](https://www.ruby-forum.com/t/session-data/87941/1 "2007-03-07T00:30:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [March 7, 2007, 5:44pm UTC](https://www.ruby-forum.com/t/session-data/87941/2 "2007-03-07T17:44:09Z")

</div>

from the console

$ script/console

> > Marshal.load(Base64.decode64(ActiveRecord::Base.connection.select\_one("select

- from sessions where session\_id = ‘’")[“data”]))

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

hope that helps

---

<div class="post-metadata">

**Author:** ![wintermute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e19b73/32.png) [@wintermute](https://www.ruby-forum.com/u/wintermute)\
**Post date:** [March 9, 2007, 12:26am UTC](https://www.ruby-forum.com/t/session-data/87941/3 "2007-03-09T00:26:16Z")

</div>

Chris H. 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
