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).
Example:
use Rack::Session::Cookie, :key => 'rack.session',
:domain => 'foo.com',
:path => '/',
:expire_after => 2592000
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.
20 21 22 23 24 25 26 |
# File 'lib/rack/session/cookie.rb', line 20 def initialize(app, ={}) @app = app @key = [:key] || "rack.session" @default_options = {:domain => nil, :path => "/", :expire_after => nil}.merge() end |
Instance Method Details
#call(env) ⇒ Object
28 29 30 31 32 |
# File 'lib/rack/session/cookie.rb', line 28 def call(env) load_session(env) status, headers, body = @app.call(env) commit_session(env, status, headers, body) end |