Index: trunk/kernel/units/general/inp_ses_storage.php =================================================================== diff -u -r3887 -r4758 --- trunk/kernel/units/general/inp_ses_storage.php (.../inp_ses_storage.php) (revision 3887) +++ trunk/kernel/units/general/inp_ses_storage.php (.../inp_ses_storage.php) (revision 4758) @@ -54,19 +54,20 @@ function LocateSession($sid) { - $query = ' SELECT '.$this->TimestampField.' FROM '.$this->TableName.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($sid); - $result = $this->Conn->GetOne($query); - - if($result===false) return false; - - $this->Expiration = $result + $this->SessionTimeout; - return true; + $res = parent::LocateSession($sid); + if ($res) { + $this->Expiration += $this->SessionTimeout; + } + return $res; } function UpdateSession(&$session) { - $query = ' UPDATE '.$this->TableName.' SET '.$this->TimestampField.' = unix_timestamp() WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID); - $this->Conn->Query($query); + $time = adodb_mktime(); + // Update LastAccessed only if it's newer than 1/10 of session timeout - perfomance optimization to eliminate needless updates on every click + if ($time - $this->DirectVars['LastAccessed'] > $this->SessionTimeout/10) { + $this->SetField($session, $this->TimestampField, $time); + } } @@ -78,15 +79,15 @@ 'IpAddress' => $_SERVER['REMOTE_ADDR'], 'GroupList' => $this->Application->ConfigValue('User_GuestGroup'), 'CurrentTempKey'=> $session->SID, - + ); - + parent::StoreSession($session, $fields_hash); } function GetExpiredSIDs() { - $query = ' SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE '.adodb_mktime().' - '.$this->TimestampField.' > '.$this->SessionTimeout; + $query = ' SELECT '.$this->IDField.' FROM '.$this->TableName.' WHERE '.$this->TimestampField.' < '.(adodb_mktime()-$this->SessionTimeout); $ret = $this->Conn->GetCol($query); if($ret) { $this->DeleteEditTables();