Class Index [+]

Quicksearch

ActionDispatch::Session::CookieStore

This cookie-based session store is the Rails default. Sessions typically contain at most a user_id and flash message; both fit within the 4K cookie size limit. Cookie-based sessions are dramatically faster than the alternatives.

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.

A message digest is included with the cookie to ensure data integrity: a user cannot alter his user_id without knowing the secret key included in the hash. New apps are generated with a pregenerated secret in config/environment.rb. Set your own for old apps you’re upgrading.

Session options:

To generate a secret key for an existing application, run “rake secret” and set the key in config/initializers/secret_token.rb.

Note that changing digest or secret invalidates all existing sessions!

Public Class Methods

new(app, options = {}) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 43
43:       def initialize(app, options = {})
44:         super(app, options.merge!(:cookie_only => true))
45:         freeze
46:       end

Private Instance Methods

destroy(env) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 84
84:         def destroy(env)
85:           # session data is stored on client; nothing to do here
86:         end
extract_session_id(env) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 56
56:         def extract_session_id(env)
57:           if data = unpacked_cookie_data(env)
58:             data["session_id"]
59:           else
60:             nil
61:           end
62:         end
load_session(env) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 50
50:         def load_session(env)
51:           data = unpacked_cookie_data(env)
52:           data = persistent_session_id!(data)
53:           [data["session_id"], data]
54:         end
persistent_session_id!(data, sid=nil) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 88
88:         def persistent_session_id!(data, sid=nil)
89:           data ||= {}
90:           data["session_id"] ||= sid || generate_sid
91:           data
92:         end
set_session(env, sid, session_data) click to toggle source
    # File lib/action_dispatch/middleware/session/cookie_store.rb, line 80
80:         def set_session(env, sid, session_data)
81:           persistent_session_id!(session_data, sid)
82:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.