Module: Merb::SessionMixin
- Defined in:
- lib/merb-core/dispatch/session/cookie.rb,
lib/merb-core/dispatch/session.rb,
lib/merb-core/dispatch/session/memory.rb,
lib/merb-core/dispatch/session/memcached.rb
Overview
:nodoc:
Class Method Summary collapse
-
.needs_new_cookie! ⇒ Object
Marks this session as needing a new cookie.
-
.rand_uuid ⇒ Object
Returns String:: A random 32 character string for use as a unique session ID.
Instance Method Summary collapse
-
#finalize_session ⇒ Object
Finalizes the session by storing the session ID in a cookie, if the session has changed.
-
#session_store_type ⇒ Object
Returns String:: The session store type, i.e.
-
#setup_session ⇒ Object
Adds a before and after dispatch hook for setting up the memcached session store.
Class Method Details
.needs_new_cookie! ⇒ Object
Marks this session as needing a new cookie.
21 22 23 |
# File 'lib/merb-core/dispatch/session.rb', line 21 def = true end |
.rand_uuid ⇒ Object
Returns
- String
-
A random 32 character string for use as a unique session ID.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/merb-core/dispatch/session.rb', line 7 def rand_uuid values = [ rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000), ] "%04x%04x%04x%04x%04x%06x%06x" % values end |
Instance Method Details
#finalize_session ⇒ Object
Finalizes the session by storing the session ID in a cookie, if the session has changed.
20 21 22 23 24 25 26 |
# File 'lib/merb-core/dispatch/session/cookie.rb', line 20 def finalize_session new_session = request.session. if @original_session != new_session (_session_id_key, new_session, Time.now + _session_expiry) end end |
#session_store_type ⇒ Object
Returns
- String
-
The session store type, i.e. “memcache”.
30 31 32 |
# File 'lib/merb-core/dispatch/session/cookie.rb', line 30 def session_store_type "cookie" end |
#setup_session ⇒ Object
Adds a before and after dispatch hook for setting up the memcached session store.
Parameters
- base<Class>
-
The class to which the SessionMixin is mixed into.
13 14 15 16 |
# File 'lib/merb-core/dispatch/session/cookie.rb', line 13 def setup_session request.session = Merb::CookieSession.new([_session_id_key], _session_secret_key) @original_session = request.session. end |