public SessionHandler::gc($lifetime)
Cleans up expired sessions (garbage collection).
Parameters
string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed:
Return value
bool true on success, false on failure
Overrides SessionHandlerInterface::gc
See also
http://php.net/sessionhandlerinterface.gc
File
- core/lib/Drupal/Core/Session/SessionHandler.php, line 121
Class
- SessionHandler
- Default session handler.
Namespace
Drupal\Core\Session
Code
public function gc($lifetime) {
// Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
// value. For example, if you want user sessions to stay in your database
// for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will his/her session be removed.
$this->connection->delete('sessions')
->condition('timestamp', REQUEST_TIME - $lifetime, '<')
->execute();
return TRUE;
}
Please login to continue.