How much can be stored in sessions?

0 views
Skip to first unread message

Jose Hales-Garcia

unread,
Aug 25, 2006, 8:34:41 PM8/25/06
to rubyonra...@googlegroups.com

How much can be stored in sessions? Can it hold model records and
their associations?

Jose

urbanus

unread,
Aug 26, 2006, 2:04:43 AM8/26/06
to Ruby on Rails: Talk
Hi Jose,

In theory, the amount you can store in a session is limited only by the
size of a "text" field in the underlying database (usually gigabytes)
if you are using ActiveRecord session storage; or the maximum size of a
file on your filesystem if you are using file storage of sessions.

And yes: you can store ActiveRecord objects in a session.

But in practice, I've had Rails throw "stack level too deep" errors
when I've had data in sessions that's very deeply linked (i.e. objects
that contain links to other objects, that contain links to others etc.
etc.). I've learnt from bitter experience that sometimes it's better
to store object IDs in the session and to fetch the objects back again
on the next request.

But as long as you don't overkill it, you might find it works fine for
you.

-- Urbanus
http://goldberg.240gl.org

Reply all
Reply to author
Forward
0 new messages