How to fix Ruby Rack SessionId error Error: undefined class/module Rack::Session::SessionId when decoding the rack.session cookie

Viewed 215

While writing a ruby script to decode rack session cookies and load the object using the ruby function Marshal load, I am getting the following error:

Error: undefined class/module Rack::Session::SessionId

This is my ruby script:

require 'pp'
require 'base64'
require 'uri'
require 'rack' # solves the error: Error: undefined class/module Rack::

c = gets
cookie, signature = c.split("--")
decoded = Base64.decode64(URI.decode(cookie))
begin
    object = Marshal.load(decoded)
    pp object
rescue ArgumentError => e
    puts "Error: " + e.to_s
end

How do I fix this? I tried looking for solutions on stackoverflow but couldn't figure it out.

1 Answers
Related