Index: branches/5.1.x/core/units/users/users_event_handler.php =================================================================== diff -u -N -r13168 -r13432 --- branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 13168) +++ branches/5.1.x/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 13432) @@ -1,6 +1,6 @@ Application->Session->DeleteExpired(); + } + + /** * Checks user data and logs it in if allowed * * OnLogin is called from u:autoLoginUser and password is supplied 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(); Index: branches/5.1.x/core/units/users/users_config.php =================================================================== diff -u -N -r13159 -r13432 --- branches/5.1.x/core/units/users/users_config.php (.../users_config.php) (revision 13159) +++ branches/5.1.x/core/units/users/users_config.php (.../users_config.php) (revision 13432) @@ -1,6 +1,6 @@ 'mode', ), - 'RegularEvents' => Array( - 'membership_expiration' => Array('EventName' => 'OnCheckExpiredMembership', 'RunInterval' => 1800, 'Type' => reAFTER), - ), + 'RegularEvents' => Array( + 'membership_expiration' => Array('EventName' => 'OnCheckExpiredMembership', 'RunInterval' => 1800, 'Type' => reAFTER), + 'delete_expired_sessions' => Array('EventName' => 'OnDeleteExpiredSessions', 'RunInterval' => 43200, 'Type' => reAFTER), + ), 'IDField' => 'PortalUserId',