session
is a method that is part of some web frameworks, for example Sinatra and Rails both have session
methods. Plain rack
applications don’t have a session
method, 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 app env
):
env['rack.session'][:msg]="Hello Rack"
Alternatively, you could use Rack’s built in request
object, like this:
request = Rack::Request.new(env)
request.session[:msg]="Hello Rack"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…