Class: Rack::Session::Cookie
- Defined in:
- lib/gems/rack-0.9.1/lib/rack/session/cookie.rb
Overview
Rack::Session::Cookie provides simple cookie based session management. The session is a Ruby Hash stored as base64 encoded marshalled data set to :key (default: rack.session). When the secret key is set, cookie data is checked for data integrity.
Example:
use Rack::Session::Cookie, :key => 'rack.session',
:domain => 'foo.com',
:path => '/',
:expire_after => 2592000,
:secret => 'change_me'
All parameters are optional.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Cookie
constructor
A new instance of Cookie.
Constructor Details
#initialize(app, options = {}) ⇒ Cookie
Returns a new instance of Cookie.
24 25 26 27 28 29 30 31 |
# File 'lib/gems/rack-0.9.1/lib/rack/session/cookie.rb', line 24 def initialize(app, ={}) @app = app @key = [:key] || "rack.session" @secret = [:secret] @default_options = {:domain => nil, :path => "/", :expire_after => nil}.merge() end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 |
# File 'lib/gems/rack-0.9.1/lib/rack/session/cookie.rb', line 33 def call(env) load_session(env) status, headers, body = @app.call(env) commit_session(env, status, headers, body) end |