I am trying to read user session data from my Magento 1.9.3.7 Redis Session in Rails 5.1.
- User logs in
- Magento Credis is set to use Zlib to compress the session data (a JSON string).
- Magento stores the compressed session data in Redis
Using redis-rb
gem:
redis = Redis.new(
host: ENV['MAGENTO_REDIS_SESSION_HOST'],
password: ENV['MAGENTO_REDIS_SESSION_PASS'],
port: ENV['MAGENTO_REDIS_SESSION_PORT'],
db: ENV['MAGENTO_REDIS_SESSION_DB']
)
data = redis.hget("sess_123456", "data")
data = data.[4..data.length]
# => data
# :gz:x\u0001\xEDWM\x8F\xDB6\u0010\...
json_string = Zlib::Inflate.inflate(data)
# => json_string
# "_secure_cookie_check|s:32:\"4d1234ebebc1234fcf1234fc1234d6da\";core|a:5:{s:23:\"_session_validator_data\";...
Note the |s:<some_number>
and a:<some_number>
in
I understand that s:32
is the length of the string 4d1234ebebc1234fcf1234fc1234d6da
.
Is this a known format? If so, what format is it?
Is there a library I can use to parse this string?
Thanks in advance!