Rails Cookie Overflow

Suddenly, in my first Rails application, I began to see this error:

/!\ FAILSAFE /!\ Fri Sep 11 17:30:48 -0400 2009 Status: 500 Internal Server Error ActionController::Session::CookieStore::CookieOverflow 

Several studies point to the use of cookies to store session data, but I am not doing this (at least not intentionally). Moreover, it has just begun today. The only thing that I started working today is the ability to download a zip file. The zip file I'm trying to use for testing is 1.1 MB.

In addition, Firebug only shows 2 cookies for this domain. The one called _html_session is 507B, and one called user_credentials is 147B. Are temporarily downloaded files saved in such a way that it can cause a large file? Uploading a single image is very simple.

Thank you for your help.

UPDATE:. Contrary to my comments on Vitaliy and Sijo below, the error is not entirely instantaneous. In this case, I load something into my Image model, and an error occurs when my ImagesController calls @image.save! .

Interestingly, I still do not understand where the error occurs. I created the Image#before_validation method Image#before_validation an exception there, but a CookieOverflow error occurs before I ever get there. Is there a place where I can reset the code after the controller completes the save call and before that specific callback? I understand that before_validation is the first callback.

+6
ruby-on-rails
source share
4 answers

The only thing that comes to mind is that you somehow put your .zip into the session.

Debug it:

  • add 'require' ruby-debug "'to your environment. rb
  • find the place where it prints the error message and put the "debugger" there.
  • run it and it will stop when it hits the 'debugger' command
  • check the call stack to see if there is anything relevant.
  • check the session at this point in time. look what exactly occupies the space there.
+3
source share

This can happen if you try to save the flash[:notice] = 'blah' message, which is too large because this message is stored in the session cookie.

+16
source share

Today I ran into a similar problem. Apparently, Rails sessions can only store 4,000 data. One possible solution is to use a database repository for your sessions.

For this:

  • Add config.action_controller.session_store = :active_record_store to your environment.rb file.
  • Create a migration file for your sessions using rake db:sessions:create
  • Run the migration rake db:migrate

Hope this helps

+8
source share

no, temporarily downloaded files are usually stored in your temp folder and have nothing to do with the cookie and its size.

What you store in your session object, and it might be nice to start storing the session object in the database if you use it constantly.

0
source share

All Articles