Sessions in Rack and Rails Metal

by Charles Max Wood on June 19, 2009

I’ve had a few requests on how to access the session from Rack and Rails Metal. In the Rack environment that is passed to the call method, the session is stored at the ‘rack.session’ index. You can use this to both read from and write to the session. Here are some examples:

session = env['rack.session']
User.find_by_id(session["user_id"])
session = env['rack.session']
session["user_id"] = 1

Leave a Comment

Previous post:

Next post: