Handling cookie overflow problem in rails

Are you getting cookie overflow error when you are loading a lot of flash[:notices] ??

Something like CGI::Session::CookieStore::CookieOverflow

if so here is a solution for it

Just write this method in ur controller

before_filter :session_cleanup

def session_cleanup
backup = session.data.clone
reset_session
backup.each { |k, v| session[k] = v unless k.is_a?(String) && k
=~ /^as:/ }
end

What this will do is it will clear old data thats already there in the session and restore this one.

The above method wont work if your data size is >= 4k in that case the only solution is to use another session store.

Hope this helps 🙂 … Njoi

Be Sociable, Share!