Removes expired sessions and auto-login keys from the database

@param string $sessionId
@param boolean $daemon
@return void
557339
public function clean(string $sessionId, $daemon = false): bool
    {
        //we sent the session id to the seassion daemon cleaner
        if (!$daemon) {
            try {
                $queue = $this->getDI()->getQueue();
                $queue->putInTube(getenv('SESSION_QUEUE'), $sessionId);
            } catch (Throwable $e) {
                //we get here if beanstalkd is down, we are moving to rabbitmq
                $this->di->getLog()->error($e->getMessage());
                return false;
            }

            return true;
        }

        $cache = $this->getDI()->getRedis();

        //
        // Delete expired sessions
        //
        $sql = "DELETE FROM  Baka\Auth\Models\Sessions
            WHERE time < :session_time:
                AND id <> :session_id: ";

        $sessionTime = time() - (int) $this->getDI()->getConfig()->jwt->payload->exp;

        $params = [
            'session_time' => $sessionTime,
            'session_id' => $sessionId,
        ];

        $result = $this->getModelsManager()->executeQuery($sql, $params);

        //
        // Delete expired keys
        //
        $sql = 'DELETE FROM Baka\Auth\Models\SessionKeys
                WHERE last_login < :last_login: ';

        $last_login = time() - (2 * (int)$this->getDI()->getConfig()->jwt->payload->exp);

        $params = ['last_login' => $last_login];

        $result = $this->getModelsManager()->executeQuery($sql, $params);

        return true;
    }
795259
public function write($sessionId, $data)
    {
        $t = microtime(true);
        $expiration = $this->_lifeTime + time();
 
        //we store time of the db record expiration in the Memcache
        if ($this->_initSessionData !== $data) {
            Kwf_Registry::get('db')->query("REPLACE INTO kwf_sessions (sessionId, expiration, data) VALUES(?, ?, ?)", array($sessionId, $expiration, $data));
            $this->_memcacheSet($sessionId, $data);
        }
        Kwf_Benchmark::count('sessionhdl', 'read: '.((microtime(true)-$t)*1000).'ms');
        return true;
    }
969186
public function destroy($sessionID): bool
    {
        $file = $this->savePath.DIRECTORY_SEPARATOR.'sess_'.$sessionID;
        $ret = \file_exists($file) ? @\unlink($file) : true;
        return $ret;
    }
809869
public function setSessionId(string $sessionId): void
    {
        if (empty($sessionId)) {
            throw new RuntimeException('CSRF middleware failed. SessionId not found!');
        }

        $this->sessionId = $sessionId;
    }
52369
public function destroy($session_id)
    {
        if (is_null($this->handlers)) {
            $this->seedHandlerStack();
        }

        /** @var callable $start */
        $start = $this->stacks['delete']->top();
        $this->handlerLock = true;
        $data = $start($session_id);
        $this->handlerLock = false;
        return $data;
    }
578834
public function destroySession(SsoServer $ssoServer, $sessionId, array $ssoClients) {
		foreach ($ssoClients as $ssoClient) {
			/** @var \Flowpack\SingleSignOn\Server\Domain\Model\SsoClient $ssoClient */
			$ssoClient->destroySession($ssoServer, $sessionId);
			$this->ssoLogger->log('Destroyed session "' . $sessionId . '" on client ' . $ssoClient->getServiceBaseUri(), LOG_INFO);
		}
	}
1164082
public static void clearSession(final String sessionId) {

		if (StringUtils.isBlank(sessionId)) {
			return;
		}

		final App app                            = StructrApp.getInstance();
		final PropertyKey<String[]> sessionIdKey = StructrApp.key(Principal.class, "sessionIds");
		final Query<Principal> query             = app.nodeQuery(Principal.class).and(sessionIdKey, new String[]{sessionId}).disableSorting();

		try {
			for (final Principal p : query.getAsList()) {

				p.removeSessionId(sessionId);
			}

		} catch (Exception fex) {

			logger.warn("Error while removing sessionId " + sessionId + " from all principals", fex);
		}

	}
1306471
public function destroy($sessionId) {
        try {
            $this->_tableRestProxy->deleteEntity($this->_sessionContainer, $this->_sessionContainerParition, $sessionId);
            return TRUE;
        } catch (ServiceException $e) {
            return FALSE;
        }
    }
659712
public function write($sessionId, $data)
    {
        $this->cache->save($this->prefix . $sessionId, $data, $this->lifetime);
    }
655890
public function session_write($sessionId, $sessionData)
    {
        $sessionData       = (!$sessionData || !is_array($sessionData)) ? [] : $sessionData;
        $this->sessionData = (!$this->sessionData) ? [] : $this->sessionData;

        $this->sessionData = array_merge($sessionData, $this->sessionData);
        $this->engine->set($this->sessionKey . $sessionId, $this->sessionData, $this->sessionLifeTime);

        return true;
    }
82527
public void expireSession(long sessionId) {
    PrimaryBackupSession session = sessions.remove(sessionId);
    if (session != null) {
      log.debug("Expiring session {}", session.sessionId());
      session.expire();
      service.expire(session.sessionId());
    }
  }
592713
public function destroy($sessionID): bool
    {
        $where = ['session_id' => $sessionID];
        $query = $this->dbClass->prepare()->delete()->from($this->dbTable)->where($where);
        $result = $this->dbClass->execute($query) == 1 ? true : false;

        return $result;
    }
1118515
public static function logout_db_session($spsessionid) {
        global $CFG, $DB;

        $sessions = $DB->get_records_sql(
            'SELECT userid, sessdata FROM {sessions} WHERE timemodified > ?',
            array(time() - $CFG->sessiontimeout)
        );

        foreach ($sessions as $session) {
            // Get user session from DB.
            if (session_decode(base64_decode($session->sessdata))) {
                if (isset($_SESSION['SESSION']) && isset($_SESSION['SESSION']->shibboleth_session_id)) {
                    // If there is a match, kill the session.
                    if ($_SESSION['SESSION']->shibboleth_session_id == trim($spsessionid)) {
                        // Delete this user's sessions.
                        \core\session\manager::kill_user_sessions($session->userid);
                    }
                }
            }
        }
    }
345008
public function getUserIdFromSessionId($sessionId)
	{
		$database = \App::get('db');

		// get session timeout period
		$timeout = \App::get('config')->get('timeout');

		// load user from session table
		$sql = "SELECT userid 
				  FROM `#__session`
				  WHERE `session_id`=" . $database->quote($sessionId) . "
				  AND time + " . (int) $timeout . " <= NOW();";
				//  AND client_id = 0;";
		$database->setQuery($sql);
		return $database->loadResult();
	}
1051535
public function destroy($session_id)
    {
        $this->pdo->queryWithParam(
            'DELETE FROM session WHERE session_id = :session_id',
            [[':session_id', $session_id, \PDO::PARAM_STR]]
        );

        return $this->pdo->getLastOperationStatus();
    }
233465
public static function doLogout($sid): bool {

		$app = Application::getInstance();
		$db  = Database::getInstance();

		// delete session
		$res = $db->exec('DELETE FROM `sessions` WHERE id = ?', $sid);

		// unset all persistent states
		$app->unsetAllPersistentStates();

		// unset RememberMe
		$app->currentUser->unsetRememberMe();
		
		// reset the user in Application object
		$app->currentUser = NULL;
		
		return (bool)$res;
	
	}
589234
public function destroy($sessionId): bool
    {
        $sql = 'DELETE FROM sessions WHERE id = :id';
        $params = ['id' => $sessionId];
        $this->db->delete($sql, $params);

        return true;
    }