use Rack::Session::Pool
...
session[:msg]="Hello Rack"
EDIT: The word session doesn’t seem to resolve. I included the Session pool middleware in my config.ru, and try to set a variable in an ERB file (I’m using Ruby Serve) and it complains “undefined local variable or method `session'”
Thanks!
sessionis a method that is part of some web frameworks, for example Sinatra and Rails both havesessionmethods. Plainrackapplications don’t have asessionmethod, unless you add one yourself.The session hash is stored in the rack env hash under the key
rack.session, so you can access it like this (assuming you’ve named the rack environment to your appenv):Alternatively, you could use Rack’s built in
requestobject, like this: