[Rt-commit] r4029 - in rt/branches/3.7-EXPERIMENTAL: . html/Elements

ruz at bestpractical.com ruz at bestpractical.com
Fri Nov 4 20:56:21 EST 2005


Author: ruz
Date: Fri Nov  4 20:56:20 2005
New Revision: 4029

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie
Log:
 r1172 at cubic-pc:  cubic | 2005-11-05 04:57:11 +0300
  r1168 at cubic-pc:  cubic | 2005-11-05 01:46:02 +0300
  * initial AutoLogoff handling
 


Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/SetupSessionCookie	Fri Nov  4 20:56:20 2005
@@ -87,6 +87,24 @@
     }
 }
 
+if ( int( $RT::AutoLogoff || 0 ) ) {
+    my $last_update = new RT::Date( RT::SystemUser );
+    if( $session_class eq 'Apache::Session::File' ) {
+        require File::Spec;
+        my $file = File::Spec->cat($RT::MasonSessionDir, $session{'_session_id'});
+        $last_update->Set( Format => 'unix', Value => (stat $file)[9] );
+    } else {
+        my $sth = $RT::Handle->SimpleQuery("SELECT LastUpdated FROM sessions WHERE id = ?", $session{'_session_id'});
+        if( $sth ) {
+            $last_update->Set( Format => 'ISO', Value => ($sth->fetchrow_array)[0] );
+        }
+    }
+
+    if ( -$last_update->Diff( time ) > $RT::AutoLogoff * 60 ) {
+        %session = ();
+    }
+}
+
 if ( !$cookies{$cookiename} ) {
     my $cookie = new CGI::Cookie(
         -name  => $cookiename,


More information about the Rt-commit mailing list