# What's the maximum storage size of a Session?

**URL:** <https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162>\
**Category:** Rails\
**Created:** [December 22, 2008, 1:07am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162 "2008-12-22T01:07:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 22, 2008, 1:07am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162/1 "2008-12-22T01:07:44Z")

</div>

Hi there,

does anyone know (for sure) how much data we can technically store in  
and later retrieve from a Rails session?

The other option to store and retrieve a really big chunk of data seems  
to be a Marshal dump+load. But since this seems more complicated than  
with a session, I’d prefer to work with the session if possible.

Thanks for your help!  
Tom

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 22, 2008, 1:19am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162/2 "2008-12-22T01:19:06Z")

</div>

Tom Ha wrote:

> does anyone know (for sure) how much data we can technically store in  
> and later retrieve from a Rails session?

Why not store it in the database? The session object should only store a  
tiny  
bit of volatile context, such as the ID of the current user…

–  
Phlip

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 22, 2008, 1:48am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162/3 "2008-12-22T01:48:22Z")

</div>

On Dec 22, 12:07 am, Tom Ha [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi there,
> 
> does anyone know (for sure) how much data we can technically store in  
> and later retrieve from a Rails session?

It depends on the store. Cookies are limited to 4k (and that’s base64  
encoded, so you actually get about 3k of storage). Database stores are  
only limited by whatever size limit the column used to store the data  
has.  
Big sessions are generally a bad idea though

Fred

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 22, 2008, 7:00am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162/4 "2008-12-22T07:00:15Z")

</div>

Thank you !

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [December 22, 2008, 2:39am UTC](https://www.ruby-forum.com/t/whats-the-maximum-storage-size-of-a-session/156162/5 "2008-12-22T02:39:17Z")

</div>

Although I have idea, I would guess that you can store as much in rails  
session as you want. Your server probably won’t like you much though.
