How to view all redis sessions? #162

Closed
krzkrzkrz opened this Issue Jan 18, 2013 · 9 comments

Comments

Projects
None yet
4 participants

Ive set up session_store to use redis_store. Typing $redis.keys in the console doesn't show my the session_store keys. Any ideas why?

Owner

jodosha commented Jan 18, 2013

It should. How that $redis is being instantiated?

$redis = Redis.new(:host => REDISTOGO_HOST, :port => REDISTOGO_PORT) in an initializer file

Owner

jodosha commented Jan 18, 2013

..and the redis-store?

Foobar::Application.config.session_store :redis_store, :servers => REDISTOGO_URL, :key_prefix => "foobar:rails:session", :expire_in => 1.week, :domain => :all

$redis.keys returns:

["aa1da443392a26492561d6c50bac6aaf", "9fffc840a35b6f7f9d50d62c6f10527c", "ea758d782463cafa12ea2d32348a088b", "e5164f6d688ad603b359069aaf703818", "c6d1a6a752439c138f6b00711f34a99f", "bfc64fffff1cb9b168241ec2d447c2c1", "3f875a59f9ba640f85b3e8fe19439ea9", "be480a22af62020e94aa8eaa8bf705df", "073893db2c5977c7c9540b9054857949", "b1570a5f1198c214d56cf5a36a795d45", "75baddc3f7289239c7e09595d17ad1ef", "602196c8d3bdf96caacd4228eae572f3", "a40592c724f8b528ff608f4e7c62c1aa", "c1c961c702f5c5a18c0f281a547262fa", "18de753b0d761511cc37258c5808584c", "73dac58360184ce3332cb1c98e10a74e", "427773b71682e81ca347048473fcea28", "1cee8e8b1e94ee708c6c48de60f4fd96", "6b70a388f8f2ab2392881b30d18ca2a6", "496f41677aa319e0b283b99e49173b33", "8b2111c191dc588dcdfa3e66652626d2", "fb18f0d7336144199e91817210b5fb4b", "0e212427f48f243c339f1a414f1f23ca", "79e6a3427739c48d21bdf0a54135a805", "2d0725beee99c9bec824354ba3270922", "fe94301ce692e0fd5a0b0540c4740c8b", "f5df603db08fd0758fce8662e2bbce33", "c194e9f7599d3eae57f4b7373d2d52a6", "c18b87508e3903ca2113f7c8d3b61d16", "4ab7fff497d5ae33506cfb6798aaa4a8", "026240ac2e98e7ae3e1280e4b06eb0eb", "2580ce1811ef4801e9be67479e60b199", "374790fe659b5665fa786e1ca63cd858", "a69fe803585f7a5984b8ed3a1f2705d2", "f25ff49f161059407013a2da4df8c5fe", "c5a0708e5c8be6958cfa9cc1f1e5a265", "cb0c3e572e4616fbd9083ba27996ea86", "3a3a7ea1561bc6d4aac3b9268dcbcc32", "b405149954e8755687857fd4d482ef04", "27f0ce690fb5a532158c066223e8960c", "70c5ba0f2f8f25749ab1af679af541b4", "2eed6daa6f9e660a4e2e09576b9d990f", "85e7de45246bf2f5753fb0e8c0dd5a08", "9b53bbfbf3aa3828f526ed015247bda4", "175cec6a5548ce4773a9b848387c2b95", "a88a90a75f934008c74aefdc56345cde"] 
Owner

jodosha commented Jan 18, 2013

I think I'm missing something. In your Redis instance there are keys that seems to be session keys. What's exactly your question?

$redis.keys does not return any keys with the prefix foobar:rails:session as defined in my session_store.rb. Shouldn't it?

Contributor

freegenie commented Jun 14, 2013

I'm closing this, please feel free to reopen it if it's still current to you.

@freegenie freegenie closed this Jun 14, 2013

nofxx commented Oct 12, 2016

Just to the annals of "How to view all redis sessions?"

Use same config as app:

r = Redis.new Rails.application.config.session_options[:servers]
r.keys 
#=> [All session keys keys, ....]

Get a user out supposing devise & warden & marshal.

u = User.find Marshal.load(r["mind-yr-namespaces:#{key}"]).values.flatten.first
# or
u = User.find Marshal.load(r["mind-yr-namespaces:#{key}"])['warden...'][0][0]

Or maybe someone knows a better way, this looks very ugly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment