I am running Rails 3 configured to use memcached for session store. I have the following setup:
development.rb
config.cache_store = :mem_cache_store
session_store.rb
Foo::Application.config.session_store :mem_cache_store, :key => '_foo_session'
I can start the app fine, when I go to any page I get the following error:
ArgumentError (key too long "rack:session:__really_long_session_key__"):
I realize the limit on memcached key is 255. How can I get around this, or am I doing something wrong?
You're almost certainly seeing this because you're switching from the cookie store to memcached. Your browser still has the old session cookie, with the long ID. You need to delete this cookie from your browser and the problem will go away.
If you're switching from cookie store to memcached on a production site, this will be a problem because you don't have control over your user's browsers. You'll probably need to change the session key to avoid problems in this case.
Is it possible you switched from the cookie store or you run other cookie session store apps on the same domain (e.g. localhost)?
In this case the cookie session store is responsible for the huge session_id string (because it actually stores the whole session in it). Just delete your session cookie and you are fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With