Changeset 1047
- Timestamp:
- 11/25/07 15:22:58 (1 year ago)
- Files:
-
- trunk/lib/merb/abstract_controller.rb (modified) (1 diff)
- trunk/lib/merb/controller.rb (modified) (1 diff)
- trunk/lib/merb/mixins/web_controller.rb (modified) (1 diff)
- trunk/lib/merb/session/cookie_store.rb (modified) (3 diffs)
- trunk/lib/merb/session/mem_cache_session.rb (modified) (1 diff)
- trunk/lib/merb/session/memory_session.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/merb/abstract_controller.rb
r967 r1047 113 113 return :filter_chain_completed 114 114 end 115 116 def finalize_session 115 116 # +finalize_session+ is called at the end of a request to finalize/store any data placed in the session. 117 # Mixins/Classes wishing to define a new session store must implement this method. 118 # See merb/lib/sessions/* for examples of built in session stores. 119 120 def finalize_session #:nodoc: 117 121 # noop 118 122 end 119 120 def setup_session 123 124 # +setup_session+ is called at the beginning of a request to load the current session data. 125 # Mixins/Classes wishing to define a new session store must implement this method. 126 # See merb/lib/sessions/* for examples of built in session stores. 127 128 def setup_session #:nodoc: 121 129 # noop 122 130 end trunk/lib/merb/controller.rb
r1017 r1047 7 7 # to your controller via params. It also parses the ?query=string and 8 8 # puts that into params as well. 9 # 10 # == Sessions 11 # 12 # Session data can be accessed through the +session+ hash: 13 # 14 # session[:user_id] = @user.id 15 # 16 # Session data is available until the user's cookie gets deleted/expires, 17 # or until your specific session store expires the data. 18 # 19 # === Session Store 20 # 21 # The session store is set in MERB_ROOT/config/merb.yml : 22 # 23 # :session_store: your_store 24 # 25 # Out of the box merb supports three session stores 26 # 27 # cookie:: All data (max 4kb) stored directly in cookie. Data integrity is checked on each request to prevent tampering. (Merb::CookieStore) 28 # memory:: Data stored in a class in memory. (Merb::MemorySession) 29 # mem_cache:: Data stored in mem_cache. (Merb::MemCacheSession) 30 # 31 # See the documentation on each session store for more information. 32 # 33 # You can also use a session store provided by a plugin. For instance, if you have DataMapper you can set 34 # 35 # :session_store: datamapper 36 # 37 # In this case session data will be stored in the database, as defined by the merb_datamapper plugin. 38 # Similar functionality exists for +activerecord+ and +sequel+ currently. 39 9 40 class Controller < AbstractController 10 41 class_inheritable_accessor :_session_id_key, :_session_expiry trunk/lib/merb/mixins/web_controller.rb
r490 r1047 1 # Used by secondary actions (a PartsController or the view) 2 # to provide the standard objects associated with each request. 3 1 4 module Merb 2 module WebControllerMixin 5 module WebControllerMixin #:nodoc: 3 6 4 7 def request trunk/lib/merb/session/cookie_store.rb
r1010 r1047 6 6 module Merb 7 7 8 module SessionMixin 8 module SessionMixin #:nodoc: 9 9 def setup_session 10 10 MERB_LOGGER.info("Setting Cookie Store Sessions") … … 15 15 end 16 16 17 def finalize_session 17 def finalize_session 18 18 MERB_LOGGER.info("Finalize Cookie Store Session") 19 19 if request.session.modified? … … 34 34 # 35 35 # A message digest is included with the cookie to ensure data integrity: 36 # a user cannot alter his user_id without knowing the secret key included in37 # the hash.36 # a user cannot alter session data without knowing the secret key included 37 # in the hash. 38 38 # 39 39 # To use Cookie Sessions, set in config/merb.yml 40 40 # :session_secret_key - your secret digest key 41 # : cookie_store_session - to true41 # :session_store: cookie 42 42 class CookieStore 43 43 # TODO (maybe): trunk/lib/merb/session/mem_cache_session.rb
r829 r1047 3 3 module Merb 4 4 5 module SessionMixin 5 module SessionMixin #:nodoc: 6 6 7 7 def setup_session trunk/lib/merb/session/memory_session.rb
r829 r1047 1 1 module Merb 2 2 3 module SessionMixin 3 module SessionMixin #:nodoc: 4 4 5 5 def setup_session … … 19 19 end 20 20 end 21 22 ## 23 # Sessions stored in memory. 24 # 25 # And a setting in +merb.yml+: 26 # 27 # :session_store: mem_cache 28 # :memory_session_ttl: 3600 (in seconds, one hour) 29 # 30 # Sessions will remain in memory until the server is stopped or the time 31 # as set in :memory_session_ttl expires. 21 32 22 33 class MemorySession
