Automatically expires the session if the user has been inactive for too long.

@return boolean TRUE if the session expired, FALSE if not
15018
protected function autoExpire()
    {
        $lastActivitySecondsAgo = time() - $this->getLastActivityTimestamp();
        $expired = false;
        if ($this->getMaximumAge() !== 0 && $lastActivitySecondsAgo > $this->getMaximumAge()) {
            $this->destroy(sprintf('Session %s was inactive for %s seconds, more than the configured timeout of %s seconds.', $this->getId(), $lastActivitySecondsAgo, $this->getMaximumAge()));
            $expired = true;
        }
        return $expired;
    }
997771
public function check() {
        if (! self::$active) {
            return;
        }
        
        // Check sessions are enabled.
        if (session_id() === '') {
            throw new \Exception('Sessions are required to use the CSRF Guard middleware.');
        }
        
        if (isset($_SESSION["csrf_time"])) {
            $expired = (time() - $_SESSION["csrf_time"]) > 3600;
        } else {
            $expired = true;
        }
        
        if (isset($_GET["expire_token"])) {
            $_SESSION["csrf_time"] = time() - 10000;
        }
        
        if (! isset($_SESSION[$this->key]) || $expired) {
            $_SESSION[$this->key] = sha1(serialize($_SERVER) . rand(0, 0xffffffff));
            $_SESSION["csrf_time"] = time();
        }
        
        $token = $_SESSION[$this->key];
        // Validate the CSRF token.
        if (in_array($this->app->request()->getMethod(), array('POST', 'PUT', 'DELETE'))) {
            $userToken = $this->app->request()->post($this->key);
       
            if ($token !== $userToken) {
                $this->app->halt(400, 'Invalid or missing or expired CSRF token.');
            }
        }
        // Assign CSRF token key and value to view.
        self::$token = $token;
    }
1184558
public function expire()
    {
        if (!isset($_SESSION[$this->_index]) || !is_array($_SESSION[$this->_index]) || empty($_SESSION[$this->_index])) {
            return;
        }

        unset($_SESSION[$this->_index]);

        // Calling session_destroy triggers the Session::destroy function which removes the entire session
        // from the database. To prevent logout issues between functionality that relies on $_SESSION, such
        // as Symphony authentication or the Members extension, only delete the $_SESSION if it empty!
        if (empty($_SESSION)) {
            session_destroy();
        }
    }
1024228
protected boolean isExpiredAt(long time) {
        try (Lock ignored = locker.lockIfNotHeld()) {
            checkValidForRead();
            return sessionData.isExpiredAt(time);
        }
    }
395836
public function expired()
    {
        if (empty($this->expiresOn)) {
            return false;
        }

        return AnDomainAttributeDate::getInstance()->toDate()->compare($this->expiresOn) > 0;
    }
68009
public function doLogout(): bool
    {
        // No user logged in
        if (empty($this->session['user'])) {
            return true;
        }

        // Store current user id for later use
        $user = $this->session['user'];

        // Remove autologin stuff?
        if ($this->remember) {
            $autologin = new Autologin($this->db);
            $autologin->setCookieName($this->cookie_name);
            $autologin->removeAutoLoginTokenAndCookie($user);
        }

        // Refresh session id and delete old session
        session_regenerate_id(true);

        // Clean up session
        unset($this->session['autologin_failed']);

        $this->session['user'] = 0;
        $this->session['logged_in'] = false;

        if (isset($this->logger)) {
            $this->logger->info('Logout: User [' . $user . ']');
        }

        return true;
    }
645889
public function isAccessTokenExpired()
  {
    if (!$this->token || !isset($this->token['created'])) {
      return true;
    }

    // If the token is set to expire in the next 30 seconds.
    $expired = ($this->token['created']
        + ($this->token['expires_in'] - 30)) < time();

    return $expired;
  }
882365
public function isExpired()
    {
        if (isset($this->_claims['exp']) && is_numeric($this->_claims['exp']))
        {
            $now  = new DateTime('now');
            return ($now->format('U') - $this->_claims['exp']) > 0;
        }

        return false;
    }
413497
public function renewRememberMe() {
		
		// build the cookie name
		$cookieName = static::getRememberMeCookieName();
		
		// check if cookie exists
		if (!isset($_COOKIE[$cookieName])) {
			return FALSE;
		}
		
		// expire in 30 days
		$expire = time() + 60*60*24*30;
		
		// set cookie and return the result
		return setcookie($cookieName, $_COOKIE[$cookieName], $expire, '/');
		
	}
604242
public function checkAccessTokenExpired()
    {
        // don't have the data? Let's assume the token has expired
        if (!isset($this->token['created_at']) || !isset($this->token['expires_in'])) {
            return true;
        }

        return ($this->token['created_at'] + $this->token['expires_in']) < time();
    }
1188006
public function check()
    {
        if ($this->_session->has('auth')) {
            // They have an auth, let's attempt to check expiration
            // and master session
            $s = [
                'session' => $this->_session->get('SCARA_SESSION'),
                'token'   => $this->_session->get('SCARA_SESSION_TOKEN'),
            ];

            $ua = $this->_ssl->untokenize($s['token'], $s['session']);

            if ($ua === hash('sha256', $_SERVER['HTTP_USER_AGENT'])) {
                $expire = $this->_session->get('expire');
                if (time() < $expire) {
                    return true;
                } else {
                    $this->logout();
                }
            }
        }

        return false;
    }
449359
protected function validSession(): bool
    {
        if (
            !array_key_exists(self::CLIENT_SIGNATURE, $_SESSION)
            || !array_key_exists(self::SESSION_CREATED, $_SESSION)
        ) {
            //Missing session signature or timestamp!
            return false;
        }

        if ($_SESSION[self::SESSION_CREATED] < time() - $this->lifetime) {
            //Session expired
            return false;
        }

        if (!hash_equals($_SESSION[self::CLIENT_SIGNATURE], $this->clientSignature)) {
            //Signatures do not match
            return false;
        }

        return true;
    }
575047
private function cleanExpired()
    {
        // 10% chance to clean the database of expired sessions
        if (mt_rand(1, 10) == 1) {
            $expiredTime = $this->now - $this->secondsUntilExpiration;
            $stmt = $this->db->prepare("DELETE FROM {$this->tableName} WHERE time_updated < {$expiredTime}");
            $stmt->execute();
        }
    }
19071
public function removeIfExpired()
    {
        if ($this->getIsExpired() && !$this->getIsNewRecord()) {
            if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
                call_user_func($this->expiredRemovingCallback, $this);
            }
            $result = $this->removeSelf();
            $this->trigger(static::$eventExpiredRemoved, new ModelEvent(['data' => ['result' => $result]]));
            return true;
        }
        return false;
    }
14811
static protected function userInfoExpiry()
    {
        /* Figure out when the last update was done */
        $handler = eZExpiryHandler::instance();
        if ( $handler->hasTimestamp( 'user-info-cache' ) )
        {
            $expiredTimestamp = $handler->timestamp( 'user-info-cache' );
        }
        else
        {
            $expiredTimestamp = time();
            $handler->setTimestamp( 'user-info-cache', $expiredTimestamp );
        }

        return $expiredTimestamp;
    }
739228
public function isActive()
    {
        $sid = defined('SID') ? constant('SID') : false;
        if ($sid !== false && session_id()) {
            return true;
        }

        if (headers_sent()) {
            return true;
        }

        return false;
    }
373202
public function isAuthenticated()
    {
        if (!$this->session->has('usr_id')) {
            return false;
        }

        if ($this->session->has('session_id')) {
            if (null !== $this->app['repo.sessions']->find($this->session->get('session_id'))) {
                return true;
            }
        }

        $this->session->invalidate();
        $this->reinitUser();

        return false;
    }