# Session and Internal server Error

**URL:** <https://www.ruby-forum.com/t/session-and-internal-server-error/124085>\
**Category:** Rails\
**Created:** [December 24, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085 "2007-12-24T13:59:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [December 24, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085/1 "2007-12-24T13:59:05Z")

</div>

Hi, Im developing an application in Rails 2.02.  
Everything seems to work fine but the problems begin when I try to put  
some data in the session.

I have a model in proyect/models:

class Result  
attr\_accessor :names, :urls, :images  
def initialize  
@names = Array.new  
@urls = Array.new  
@images = Array.new  
end  
end

Controller:  
@variable = Result.new  
#code that fills up the values in the result arrays.  
session[:result] = @result

I fill these attributes from a controller. At the end, if I try to put  
the variable into the session I get the msg:

Status: 500 Internal Server Error Content-Type: text/html  
500 Internal Server Error

Any ideas? thanks!

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [December 24, 2007, 2:20pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085/2 "2007-12-24T14:20:45Z")

</div>

This is the trace of the log

Rendering /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/templates/rescues/layout.erb (internal\_server\_error)  
/!\ FAILSAFE /!\ Mon Dec 24 14:19:02 +0100 2007  
Status: 500 Internal Server Error  
CGI::Session::CookieStore::CookieOverflow  
/Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/  
session/cookie\_store.rb:112:in `close’

Is it too big what I’m trying to store in the session?

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [December 24, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085/3 "2007-12-24T14:26:36Z")

</div>

On 24 Dec 2007, at 12:58, Javier Q. wrote:

> @names = Array.new  
> I fill these attributes from a controller. At the end, if I try to put  
> the variable into the session I get the msg:

There should be a full stack trace in your log files.  
Are you putting anything unserializable in your session?

Fred

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [December 24, 2007, 2:27pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085/4 "2007-12-24T14:27:11Z")

</div>

On Dec 24, 2007, at 2:20 PM, Javier Q. wrote:

> Rendering /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/  
> action\_controller/templates/rescues/layout.erb (internal\_server\_error)  
> /!\ FAILSAFE /!\ Mon Dec 24 14:19:02 +0100 2007  
> Status: 500 Internal Server Error  
> CGI::Session::CookieStore::CookieOverflow  
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/  
> session/cookie\_store.rb:112:in `close’
> 
> Is it too big what I’m trying to store in the session?

In your snippet there’s this comment:

```
#code that fills up the values in the result arrays.

```

I guess the resulting cookie value after you populate the inner arrays  
(think whole object tree marshalled + Base64 encoding + two dashes +  
digest) is \> 4K.

Do you really need such an object in the session. If yes then you’d  
need to switch to a different storage.

– fxn

---

<div class="post-metadata">

**Author:** ![Javier\_Q](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@Javier\_Q](https://www.ruby-forum.com/u/Javier_Q)\
**Post date:** [December 24, 2007, 2:49pm UTC](https://www.ruby-forum.com/t/session-and-internal-server-error/124085/5 "2007-12-24T14:49:02Z")

</div>

Thanks. I didn’t know that you could only store 4Kb in size in the  
session. I guess that I will use a database to store it then.  
Thanks for your fast reply!
