Garbage collect stale sessions from the SessionHandler backend.

@param   integer  $lifetime  The maximum age of a session.

@return  boolean  True on success, false otherwise.

@since   1.0
@deprecated  2.0
542057
public function gc($lifetime = 1440)
	{
		// Determine the timestamp threshold with which to purge old sessions.
		$past = time() - $lifetime;

		try
		{
			$query = $this->db->getQuery(true);
			$query->delete($this->db->quoteName('#__session'))
				->where($this->db->quoteName('time') . ' < ' . $this->db->quote((int) $past));

			// Remove expired sessions from the database.
			$this->db->setQuery($query);

			return (boolean) $this->db->execute();
		}
		catch (\Exception $e)
		{
			return false;
		}
	}
780362
public function gc($lifetime): bool
    {
        $pattern = $this->savePath . \DIRECTORY_SEPARATOR . $this->prefix . '*';
        foreach (\glob($pattern) as $file) {
            if (\filemtime($file) + $lifetime < \time() && \file_exists($file)) {
                \unlink($file);
            }
        }

        return true;
    }
499477
public function collectGarbage()
    {
        if ($this->inactivityTimeout === 0) {
            return 0;
        }
        if ($this->metaDataCache->has('_garbage-collection-running')) {
            return false;
        }

        $sessionRemovalCount = 0;
        $this->metaDataCache->set('_garbage-collection-running', true, [], 120);

        foreach ($this->metaDataCache->getIterator() as $sessionIdentifier => $sessionInfo) {
            if ($sessionIdentifier === '_garbage-collection-running') {
                continue;
            }
            $lastActivitySecondsAgo = $this->now - $sessionInfo['lastActivityTimestamp'];
            if ($lastActivitySecondsAgo > $this->inactivityTimeout) {
                if ($sessionInfo['storageIdentifier'] === null) {
                    $this->logger->warning('SESSION INFO INVALID: ' . $sessionIdentifier, $sessionInfo + LogEnvironment::fromMethodName(__METHOD__));
                } else {
                    $this->storageCache->flushByTag($sessionInfo['storageIdentifier']);
                    $sessionRemovalCount++;
                }
                $this->metaDataCache->remove($sessionIdentifier);
            }
            if ($sessionRemovalCount >= $this->garbageCollectionMaximumPerRun) {
                break;
            }
        }

        $this->metaDataCache->remove('_garbage-collection-running');
        return $sessionRemovalCount;
    }
403801
public function gc($lifeTime) {
        // search the entities that need to be deleted.
        $filter = 'PartitionKey eq\'' . $this->_sessionContainerPartition . '\' and expires lt ' . (time() - $lifeTime);
        try {
            $result = $this->_tableRestProxy->queryEntities($this->_sessionContainer, $filter);
            $entities = $result->getEntities();
            foreach ($entities as $entitiy) {
                $this->_tableRestProxy->deleteEntity($this->_sessionContainer, $this->_sessionContainerParition, $entity->getRowKey());
            }
            return TRUE;
        } catch (ServiceException $e) {
            return FALSE;
        }
    }
321001
public function getControledLifetime($lifetime)
    {
        if (
            null !== $this->_instance_options['min_lifetime']
            && $this->_instance_options['min_lifetime'] > $lifetime
        ) {
            $lifetime = $this->_instance_options['min_lifetime'];
        } elseif (
            null !== $this->_instance_options['max_lifetime']
            && $this->_instance_options['max_lifetime'] < $lifetime
        ) {
            $lifetime = $this->_instance_options['max_lifetime'];
        }

        return $lifetime;
    }
583259
public function isExpired()
    {
        $this->validatePrepared();

        if (!$this->sessionBag->has(self::CSRF_TKN_TIME)) {
            return true;
        } else {
            $age = time() - $this->sessionBag->get(self::CSRF_TKN_TIME);
            return $age >= $this->ttl;
        }
    }
931318
public static function prolong($name, $lifetime)
    {
        $item = static::reach($name);

        if ($item['lifetime'] > 0) {
            $item['lifetime'] += $lifetime;
        } elseif ($item['lifetime'] == 0) {
            $item['lifetime'] = time() + $lifetime;
        }

        static::$register[$name] = $item;

        static::save();

        return true;
    }
425308
private function _getFastLifetime($lifetime, $priority, $maxLifetime = null)
    {
        if ($lifetime <= 0) {
            // if no lifetime, we have an infinite lifetime
            // we need to use arbitrary lifetimes
            $fastLifetime = (int) (2592000 / (11 - $priority));
        } else {
            // prevent computed infinite lifetime (0) by ceil
            $fastLifetime = (int) ceil($lifetime / (11 - $priority));
        }

        if ($maxLifetime >= 0 && $fastLifetime > $maxLifetime) {
            return $maxLifetime;
        }

        return $fastLifetime;
    }
537043
private function assignSessionLifetime()
    {
        if (isset($this->configurations['lifetime'])) {
            $lifetime = $this->configurations['lifetime'];
            ini_set('session.gc_maxlifetime', $lifetime * 1.2);
            session_set_cookie_params($lifetime);
        }
    }
568879
public function isExpired()
    {
        $curTime = $this->timer['now'];
        $maxTime = $this->timer['last'] + $this->_lifetime;

        return ($maxTime < $curTime);
    }
1073232
public function gc($maxlifetime)
    {
        $sql = 'DELETE FROM ' . $this->config['name']
            . ' WHERE ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' < ?';

        $this->query($sql, array(time()));

        return true;
    }
908698
public function setLifeTime($lifeTime = null)
    {
        $this->lifeTime = ((is_null($lifeTime)) ? $this->defaultTime : $lifeTime) * 60;

        return true;
    }
286761
def query_by_expired(cls):
        """"""
        lifetime = current_app.permanent_session_lifetime
        expired_moment = datetime.utcnow() - lifetime
        return cls.query.filter(cls.created < expired_moment)
651777
public function gc($maxlifetime)
    {
        $platform = $this->tableGateway->getAdapter()->getPlatform();

        $where = new Where();
        $where->lessThan(
            $this->options->getModifiedColumn(),
            new Expression('(' . time() . ' - ' . $platform->quoteIdentifier($this->options->getLifetimeColumn()) . ')')
        );

        $rows = $this->tableGateway->select($where);

        $ids = [];

        /* @var \UthandoSessionManager\Model\SessionModel $row */
        foreach ($rows as $row) {
            $ids[] = $row->{$this->options->getIdColumn()};
        }

        if (count($ids) > 0) {
            $where = new Where();
            $result = (bool) $this->tableGateway->delete(
                $where->in($this->options->getIdColumn(), $ids)
            );
        } else {
            $result = false;
        }

        return $result;
    }
1115251
public function gcSession($maxLifetime)
    {
        $this->db->getCollection($this->sessionCollection)
            ->remove(['expire' => ['$lt' => time()]]);

        return true;
    }
469685
protected function expiration($key)
	{
		$lifetime = ini_get("session.gc_maxlifetime");

		$expire = $this->engine->get($key . '_expire');

		// Set prune period
		if ($expire + $lifetime < time())
		{
			$this->engine->delete($key);
			$this->engine->delete($key . '_expire');
		}
		else
		{
			$this->engine->replace($key . '_expire', time());
		}
	}
1301307
public function gc($maxlifetime)
    {
        $timestamp = time() - $maxlifetime;

        if ($this->disableLog) {
            Log::temporaryDisable('sql');
        }

        try {
            $this->getAdapter()->delete($this->getTableName())->where('time', '<', $timestamp)->exec();
            return true;

        } catch (DbException $e) {
            Log::emergency($e);
            return false;

        } finally {
            if ($this->disableLog) {
                Log::restoreTemporaryDisablement();
            }
        }
    }