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.
# File lib/rack/session/cookie.rb, line 44 def call(env) load_session(env) status, headers, body = @app.call(env) commit_session(env, status, headers, body) end
# File lib/rack/session/cookie.rb, line 26 def initialize(app, options={}) @app = app @key = options[:key] || "rack.session" @secret = options[:secret] warn " SECURITY WARNING: No secret option provided to Rack::Session::Cookie. This poses a security threat. It is strongly recommended that you provide a secret to prevent exploits that may be possible from crafted cookies. This will not be supported in future versions of Rack, and future versions will even invalidate your existing user cookies. Called from: #{caller[0]}. " unless @secret @default_options = {:domain => nil, :path => "/", :expire_after => nil}.merge(options) end