50e30c0f131fac8055ad372a780a495055a627fe
[rails.git] / vendor / plugins / session-persistence / lib / session_persistence.rb
1 module SessionPersistence
2   private
3   
4   # Override this method if you don't want to use session[:_remember_for].
5   def session_persistence_key
6     :_remember_for
7   end
8
9   # Persist the session.
10   #
11   #   session_expires_after 1.hour
12   #   session_expires_after 2.weeks
13   def session_expires_after(seconds)
14     session[session_persistence_key] = seconds 
15   end
16   
17   # Expire the session.
18   def session_expires_automatically
19     session.delete(session_persistence_key)
20   end
21   alias_method :expire_session, :session_expires_automatically
22   
23   def _persist_session
24     if session[session_persistence_key]
25       request.session_options = request.session_options.dup
26       request.session_options[:expire_after] = session[session_persistence_key]
27       request.session_options.freeze
28     end
29   end
30 end