b556f04649063162cb2d20a7a5a5c041ebd58eba
[feedcatcher.git] / vendor / rails / actionpack / lib / action_controller / session_management.rb
1 module ActionController #:nodoc:
2 module SessionManagement #:nodoc:
3 def self.included(base)
4 base.class_eval do
5 extend ClassMethods
6 end
7 end
8
9 module ClassMethods
10 # Set the session store to be used for keeping the session data between requests.
11 # By default, sessions are stored in browser cookies (<tt>:cookie_store</tt>),
12 # but you can also specify one of the other included stores (<tt>:active_record_store</tt>,
13 # <tt>:mem_cache_store</tt>, or your own custom class.
14 def session_store=(store)
15 if store == :active_record_store
16 self.session_store = ActiveRecord::SessionStore
17 else
18 @@session_store = store.is_a?(Symbol) ?
19 Session.const_get(store.to_s.camelize) :
20 store
21 end
22 end
23
24 # Returns the session store class currently used.
25 def session_store
26 if defined? @@session_store
27 @@session_store
28 else
29 Session::CookieStore
30 end
31 end
32
33 def session=(options = {})
34 self.session_store = nil if options.delete(:disabled)
35 session_options.merge!(options)
36 end
37
38 # Returns the hash used to configure the session. Example use:
39 #
40 # ActionController::Base.session_options[:secure] = true # session only available over HTTPS
41 def session_options
42 @session_options ||= {}
43 end
44
45 def session(*args)
46 ActiveSupport::Deprecation.warn(
47 "Disabling sessions for a single controller has been deprecated. " +
48 "Sessions are now lazy loaded. So if you don't access them, " +
49 "consider them off. You can still modify the session cookie " +
50 "options with request.session_options.", caller)
51 end
52 end
53 end
54 end