]> git.openstreetmap.org Git - rails.git/blob - vendor/plugins/session-persistence/lib/session_persistence.rb
2fac6033257c89b8fe9762e19e0351aa0cb42c9d
[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[:expires] = Time.now + session[session_persistence_key]
26       request.session_options[:expire_after] = session[session_persistence_key]
27     end
28   end
29 end