Class Rack::Session::Cookie
In: lib/rack/session/cookie.rb
Parent: Abstract::ID

Rack::Session::Cookie provides simple cookie based session management. By default, the session is a Ruby Hash stored as base64 encoded marshalled data set to :key (default: rack.session). The object that encodes the session data is configurable and must respond to encode and decode. Both methods must take a string and return a string.

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.

Example of a cookie with no encoding:

  Rack::Session::Cookie.new(application, {
    :coder => Racke::Session::Cookie::Identity.new
  })

Example of a cookie with custom encoding:

  Rack::Session::Cookie.new(application, {
    :coder => Class.new {
      def encode(str); str.reverse; end
      def decode(str); str.reverse; end
    }.new
  })

Methods

new  

Classes and Modules

Class Rack::Session::Cookie::Base64
Class Rack::Session::Cookie::Identity
Class Rack::Session::Cookie::Reverse

Attributes

coder  [R] 

Public Class methods

[Validate]