Class Merb::CookieSession
In: lib/merb-core/dispatch/session/cookie.rb
Parent: Object

If you have more than 4K of session data or don‘t want your data to be visible to the user, pick another session store.

CookieOverflow is raised if you attempt to store more than 4K of data. TamperedWithCookie is raised if the data integrity check fails.

A message digest is included with the cookie to ensure data integrity: a user cannot alter session data without knowing the secret key included in the hash.

To use Cookie Sessions, set in config/merb.yml

 :session_secret_key - your secret digest key
 :session_store: cookie

Methods

[]   []=   delete   each   new   read_cookie  

Classes and Modules

Class Merb::CookieSession::CookieOverflow
Class Merb::CookieSession::TamperedWithCookie

Constants

MAX = 4096   Cookies can typically store 4096 bytes.
DIGEST = OpenSSL::Digest::Digest.new('SHA1')

Attributes

data  [R] 

Public Class methods

Parameters

cookie<String>:The cookie.
secret<String>:A session secret.

Raises

ArgumentError:Nil or blank secret.

Public Instance methods

Parameters

k<~to_s>:The key of the session parameter to retrieve.

Returns

String:The value of the session parameter.

Parameters

k<~to_s>:The key of the session parameter to set.
v<~to_s>:The value of the session parameter to set.

Deletes the session by emptying stored data.

Yields the session data to an each block.

Parameter

&b:The block to pass to each.

Returns

String:Cookie value.

Raises

CookieOverflow:Session contains too much information.

[Validate]