1
ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
actionpack (4.2.8) lib/action_dispatch/middleware/cookies.rb:529:in `[]='

I am getting this error when hitting redmine rest api. The simple get api like url1 works fine but when it come to complex url as url2 the application throws cookie overflow.

url1: localhost:3000/issues.json?page=1&limit=100
url2: http://localhost:3000/issues.json?key=292fe116d13d5f5db8a0e3f2b031f1e57ad1c882&f[]=project_id&op[project_id]=!&v[project_id][]=505&f[]=project_id&op[project_id]=!&v[project_id][]=478&f[]=project_id&op[project_id]=!&v[project_id][]=366&f[]=project_id&op[project_id]=!&v[project_id][]=419&f[]=project_id&op[project_id]=!&v[project_id][]=343&f[]=project_id&op[project_id]=!&v[project_id][]=345&f[]=project_id&op[project_id]=!&v[project_id][]=512&f[]=project_id&op[project_id]=!&v[project_id][]=487&f[]=project_id&op[project_id]=!&v[project_id][]=473&f[]=project_id&op[project_id]=!&v[project_id][]=509&f[]=project_id&op[project_id]=!&v[project_id][]=520&f[]=project_id&op[project_id]=!&v[project_id][]=404&f[]=project_id&op[project_id]=!&v[project_id][]=440&f[]=project_id&op[project_id]=!&v[project_id][]=389&f[]=project_id&op[project_id]=!&v[project_id][]=467&f[]=project_id&op[project_id]=!&v[project_id][]=501&f[]=project_id&op[project_id]=!&v[project_id][]=474&f[]=project_id&op[project_id]=!&v[project_id][]=471&f[]=project_id&op[project_id]=!&v[project_id][]=480&f[]=project_id&op[project_id]=!&v[project_id][]=507&f[]=project_id&op[project_id]=!&v[project_id][]=383&f[]=project_id&page=1&limit=100

I have not stored anything but username, cas ticket in session as:

 request.session['cas'] = { 'user' => user, 'ticket' => ticket, 'extra_attributes' => [] }

I have searched for the solution in many forums. All said donot save unnecessary data but all i am saving are username and cas ticket. When i print session this is the result:

puts(session.to_hash)

{"session_id"=>"fbe61cf9fd1c2ef0111d5d84a1a374c2", "cas"=>{"user"=>"user@gmail.com", "ticket"=>"ST-27189-R20MW7GBWaLWNJvl1aMi-localhost", "extra_attributes"=>[]}}

But when inspect session as below i get loads of gibberish data like below.I saw that the ActiveRecord stuff and query params from the GET is indeed part of the session.

puts(session.inspect)

[result]: https://textsaver.flap.tv/lists/3caw "Click here for session.inspect output"

Since i am a newbie and just starting ruby on rails any suggestions will be highly appreciated. Thank You.

1 Answers1

1

That second url with many parameters is quite long and it bloats session since it is present in original_fullpath, query_string and other variables in session. And cookie store has limits - there is only 4kb.

I suggest to change session store from cookie to database or memcache as explained in linked answers.

Edit: Up-to-date info can be found in docs.

Pavel Oganesyan
  • 6,774
  • 4
  • 46
  • 84
  • those links are from 5 -8 years ago, are they still useful? – Mayra Navarro Jun 12 '20 at 17:59
  • 1
    @MayraNavarro original question was about ruby-on-rails-3, so I thought it will be OK to provide info relevant to that time. Now there are some differences: memcache is somewhat deprecated (use CacheStore instead) and storing sessions in database requires gem. I added new link to the answer, thank you. – Pavel Oganesyan Jun 15 '20 at 11:09