Index: branches/5.1.x/core/kernel/session/session.php =================================================================== diff -u -N -r13086 -r13432 --- branches/5.1.x/core/kernel/session/session.php (.../session.php) (revision 13086) +++ branches/5.1.x/core/kernel/session/session.php (.../session.php) (revision 13432) @@ -1,6 +1,6 @@ IDField.' FROM '.$this->TableName.' WHERE '.$this->TimestampField.' > '.adodb_mktime(); - return $this->Conn->GetCol($query); + $sql = 'SELECT ' . $this->IDField . ' + FROM ' . $this->TableName . ' + WHERE ' . $this->TimestampField . ' > ' . adodb_mktime(); + + return $this->Conn->GetCol($sql); } function DeleteExpired() { $expired_sids = $this->GetExpiredSIDs(); + if ($expired_sids) { $sessionlog_table = $this->Application->getUnitOption('session-log', 'TableName'); - $session_log_sql = - ' UPDATE '.$sessionlog_table.' - SET Status = 2, SessionEnd = - ( SELECT '.$this->TimestampField.' - '.$this->SessionTimeout.' - FROM '.$this->TableName.' - WHERE '.$this->IDField.' = '.$sessionlog_table.'.SessionId - ) - WHERE Status = 0 AND SessionId IN ('.join(',', $expired_sids).')'; + if ($sessionlog_table) { + $sub_select = ' SELECT ' . $this->TimestampField . ' - ' . $this->SessionTimeout . ' + FROM ' . $this->TableName . ' + WHERE ' . $this->IDField . ' = ' . $sessionlog_table . '.SessionId'; + + $session_log_sql = + ' UPDATE ' . $sessionlog_table . ' + SET Status = ' . SESSION_LOG_EXPIRED . ', SessionEnd = (' . $sub_select . ') + WHERE Status = ' . SESSION_LOG_ACTIVE . ' AND SessionId IN (' . implode(',', $expired_sids) . ')'; $this->Conn->Query($session_log_sql); } - $where_clause = ' WHERE '.$this->IDField.' IN ("'.implode('","',$expired_sids).'")'; - $sql = 'DELETE FROM '.$this->SessionDataTable.$where_clause; + $where_clause = ' WHERE ' . $this->IDField . ' IN ("' . implode('","', $expired_sids) . '")'; + + $sql = 'DELETE FROM ' . $this->SessionDataTable . $where_clause; $this->Conn->Query($sql); - $sql = 'DELETE FROM '.$this->TableName.$where_clause; + $sql = 'DELETE FROM ' . $this->TableName . $where_clause; $this->Conn->Query($sql); // delete debugger ouputs left of expired sessions @@ -334,6 +340,7 @@ } } } + return $expired_sids; } @@ -601,7 +608,7 @@ return ; } - $this->DeleteExpired(); +// $this->DeleteExpired(); // called from u:OnDeleteExpiredSessions agent now if ($this->expired || ($this->CachedSID && !$this->_fromGet && !$this->SessionSet)) { $this->RemoveSessionCookie();