1 # Provides the ability to have session cookies for your Rails app calculated
2 # relative to the current time.
4 # In your environment.rb file (or in the environments/*.rb file of your choice),
5 # do something like the following:
7 # CGI::Session.expire_after 1.month
9 # Session cookies will then expire one month after the session was created. This
10 # differs from the usual session cookie behavior in that the expiration date is
11 # not a fixed time, but rather relative to the current time.
15 @@session_expiration_offset = 0
17 def self.session_expiration_offset
18 @@session_expiration_offset
21 def self.session_expiration_offset=(value)
22 @@session_expiration_offset = value
25 def self.expire_after(value)
26 @@session_expiration_offset = value
29 alias :initialize_without_dynamic_session_expiration :initialize #:nodoc:
30 def initialize(request, option={}) #:nodoc:
31 if @@session_expiration_offset && @@session_expiration_offset > 0
32 option['session_expires'] = Time.now + @@session_expiration_offset
34 initialize_without_dynamic_session_expiration(request, option)