开发者

Rack session key too long for memcached

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 t开发者_如何学Goo 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 your "key" is more than 255 characters, it sounds like you are doing something wrong. Why is your session key that long? What's wrong with MD5 or SHA1?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜