Checks if the given session is still valid.

@param $session

@return bool
@throws LoginException
509752
private function isSessionValid($session)
    {
        $sessions = $this->getMeta()->sessions;
        $sessionTtl = $this->getSessionTtl();

        foreach ($sessions as $s) {
            if ($s['sid'] == $session && ($s['created'] + $sessionTtl) > time()) {
                return true;
            }
        }

        return false;
    }
124264
public function isValid(): bool {
		return ($this->loginContext->hasCurrentUser()
				&& $this->loginContext->getCurrentUser()->isAdmin()) || N2N::isDevelopmentModeOn();
	}
51074
protected function startSession($session)
    {
        if (is_bool($session) || is_string($session)) {
            if ($session === false || isset($_SESSION)) {
                return;
            }

            if (is_string($session)) {
                session_name($session);
            }

            return session_start();
        }

        $prefix = 'Session variable must be of type \'boolean\' or \'string\', \'';

        throw new \InvalidArgumentException($prefix . gettype($session) . '\' given.');
    }
503430
protected function validateSessionObject($session) {
    // Make sure some essential fields exist.
    if (is_array($session) && isset($session['access_token']) && isset($session['sig'])) {
      // Validate the signature.
      $session_without_sig = $session;
      unset($session_without_sig['sig']);

      $expected_sig = self::generateSignature(
        $session_without_sig,
        $this->getVariable('client_secret')
      );

      if ($session['sig'] != $expected_sig) {
        error_log('Got invalid session signature in cookie.');
        $session = NULL;
      }
    }
    else {
      $session = NULL;
    }
    return $session;
  }
1040583
public function isLoggedIn()
    {
        $loggedIn = $this->di->get("session")->has("user");
        if (!$loggedIn) {
            $this->di->get("response")->redirect("user/login");
            return false;
        }
        return true;
    }
1189180
public function isValid($value)
    {
        $valid = true;
        $this->setValue($value);

        $result = $this->query($value);
        if (!$result) {
            if ($result === false) {
                $valid = false;
                $this->error(self::ERROR_NOT_ACTIVE);
            } elseif ($this->getOption('property') !== 'NOT_ACTIVE') {
                $valid = false;
                $this->error(self::ERROR_NO_RECORD_FOUND);
            }
        }

        return $valid;
    }
34256
public function isValid(SessionBagInterface $sessionBag)
    {
        return $sessionBag->get(self::PARAM_REMOTE_ADDR) === $this->hash($this->getRemoteAddr()) &&
               $sessionBag->get(self::PARAM_USER_AGENT) === $this->hash($this->getUserAgent());
    }
707612
protected function validate()
    {
        // Are needed session variables set ?
        if (!isset($_SESSION['s3ss10nCr3at3d']) || !isset($_SESSION['n3k0t'])) {
            return false;
        }

        // Check if session token match ?
        if ($this->matchUserAgent) {
            if ($_SESSION['n3k0t'] !== hash_hmac($this->hashAlgo, $_SERVER['HTTP_USER_AGENT'] . $_SESSION['s3ss10nCr3at3d'], $this->hashKey)) {
                return false;
            }
        } elseif ($_SESSION['n3k0t'] !== hash_hmac($this->hashAlgo, $_SESSION['s3ss10nCr3at3d'], $this->hashKey)) {
            return false;
        }

        // Is session expired ?
        if ((time() > ($_SESSION['s3ss10nCr3at3d']) + $this->expiration)) {
            return false;
        }

        // Everything is fine return true
        return true;
    }
863339
public function has($name):bool
    {
        return ((isset($this->session[$name]) && null != $this->session[$name])? true : false);
    }
616334
private boolean isSessionValid(final SessionData session) {
        return !sessionController.isCreatingSession() && session != null && session.getSessionId() != null && session.getAccessToken() != null;
    }
1293576
public function findFromSession(Session $session)
    {
        $this->addWhere('user_email', $session->get('email'));
        $this->addWhere('user_id',    (int) $session->get('id'));
        $this->addWhere('user_is_activated', 1);

        try {
            $user = $this->selectOne();
        } catch (ExceptionNoData $exception) {
            throw new LoginException('Login and / or password is incorrect!', 1000, $exception);
        }

        return $user;
    }
910133
public function validLoggedInAdmin()
    {
        $loggedInUser = $this->getCurrentLoggedInUser();
        if ($loggedInUser
            && $loggedInUser->administrator
            && $loggedInUser->deleted === null
            && $loggedInUser->enabled) {
                return true;
        }
        return false;
    }
1245475
public function isLogined()
    {
        $session = $this->getSession();
        $cookie = $this->getCookie();

        if ($cookie->has(self::USER_SESSION)) {
            $login = $cookie->get(self::USER_SESSION);
            $login = unserialize(base64_decode($login));
        }elseif (false !== $session->has(self::USER_SESSION)) {
            $login = $session->get(self::USER_SESSION);
        }else{
            return false;
        }

        return $this->isSameIp($login);
    }
1027337
protected function getSessionId(Session $session)
	{
		$driver = $session->getDriver();

		if ( $driver instanceof Selenium2Driver ) {
			return $driver->getWebDriverSessionId();
		}

		throw new \RuntimeException('Unsupported session driver');
	}
1029203
public static function valid() {
		if (static::start() && static::read('Config')) {
			if (static::_validAgentAndTime() && static::$error === false) {
				static::$valid = true;
			} else {
				throw new InternalErrorException('Session Highjacking Attempted !!!');
			}
		}
		return static::$valid;
	}
557775
public static function hasSessionMoved() {
		if(!isset($_SESSION['dachi_agent']))
			return true;

		$agents = $_SESSION['dachi_agent'];
		$agentc = $_SERVER['HTTP_USER_AGENT'];

		if($agents != $agentc) {
			if(strpos($agentc, "Trident") !== false && strpos($agents, "Trident") !== false)
				return false;

			return true;
		}

		return false;
	}
1292743
public function isValid($action) {
		$authCtrl=$this->_getAuthController();
		$isValid=$authCtrl->_isValidUser($action);
		if(!$isValid){
			$authCtrl->_autoConnect();
			return $authCtrl->_isValidUser($action);
		}
		return $isValid;
	}