Class: Rack::Session::Cookie
- Inherits:
-
Object
- Object
- Rack::Session::Cookie
- Defined in:
- 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.
26 27 28 29 30 31 32 33 |
# File 'lib/rack/session/cookie.rb', line 26 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
35 36 37 38 39 |
# File 'lib/rack/session/cookie.rb', line 35 def call(env) load_session(env) status, headers, body = @app.call(env) commit_session(env, status, headers, body) end |