You’ve got a 4kb limit on what you can store in a cookie, and when Rails converts your object into text for writing to the cookie its probably bigger than that limit.
Ruby on Rails ActionDispatch::Cookies::CookieOverflow
error
That way this CookieOverflow
Error occurs.
The easiest way to solve this one is, you need change your session_store and don’t use the cookie_store
. You can use the active_record_store
by example.
Here is the steps
-
Generate a migration that creates the session table
rake db:sessions:create
-
Run the migration
rake db:migrate
-
Modify
config/initializers/session_store.rb
from(App)::Application.config.session_store :cookie_store, :key => 'xxx'
to
(App)::Application.config.session_store :active_record_store
Once you’ve done the three steps, restart your application. Rails will now use the sessions table to store session data,
and you won’t have the 4kb limit.