Validates a session_version = 3 style session object.

@param $session
The session object.

@return
The session object if it validates, NULL otherwise.
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;
  }
472491
private function storeUserSession($session)
    {
        // get all sessions
        $sessions = $this->getMeta()->sessions->val();
        if (!is_array($sessions)) {
            $sessions = [];
        }

        // delete the old sessions
        $newSessions = [];
        $ttl = $this->getSessionTtl();
        foreach ($sessions as $s) {
            if (($s['created'] + $ttl) > time()) {
                $newSessions[] = $s;
            }
        }

        // append the new session
        $newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];

        // update the last login date
        $this->getMeta()->lastLogin = time();

        // append a new login attempt
        $this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];

        // update the entity
        $this->getMeta()->sessions = $newSessions;
        $this->getMeta()->save();
    }
1299535
public static function getVerify()
    {
        $verify = Session::get(self::$sessionKey);
        Session::set(self::$sessionKey, null);
        return $verify;
    }
826020
public static function validate($access)
    {
        $lowercaseAccess = \strtolower($access);

        if ('subscription' === $lowercaseAccess || 'registration' === $lowercaseAccess) {
            return \ucfirst($lowercaseAccess);
        }

        return false;
    }
141456
protected function validate($session, $request)
    {
        $locked = $session->get(self::LOCKED_FIELD);
        return !($locked['ip'] != $request->getClientIp()
            || $locked['agent'] != md5($request->server('HTTP_USER_AGENT')));
    }
1021280
private function get($key) {
		if (isset($_SESSION[self::SESSION_KEY_FLASH]) && isset($_SESSION[self::SESSION_KEY_FLASH][$key])) {
			$message = $_SESSION[self::SESSION_KEY_FLASH][$key];

			unset($_SESSION[self::SESSION_KEY_FLASH][$key]);

			return $message;
		}
		else {
			return null;
		}
	}
182591
public function destroy(Session $session)
    {
        $session->delete();

        return intend([
            'back' => true,
            'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/auth::common.session'), 'identifier' => $session->getKey()])],
        ]);
    }
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;
    }
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;
    }
1117043
public function validateEntity($entity)
    {
        $description = $entity->getEntityDescription();

        //if entity is persisted only look at the modified
        //properties
        if ($entity->isModified()) {
            $properties = array_intersect_key($description->getProperty(), AnConfig::unbox($entity->getModifiedData()));
        } else {
            $properties = $description->getProperty();
        }

        foreach ($properties as $property) {
            $value = $entity->get($property->getName());
            $entity->getValidator()->validateData($entity, $property, $value);
        }

        return $entity->getErrors()->count() === 0;
    }
890208
@Nonnull
  public static EChange safeInvalidateSession (@Nullable final HttpSession aSession)
  {
    if (aSession != null)
    {
      try
      {
        if (LOGGER.isDebugEnabled ())
          LOGGER.debug ("Invalidating session " + aSession.getId ());
        aSession.invalidate ();
        return EChange.CHANGED;
      }
      catch (final IllegalStateException ex)
      {
        // session already invalidated
      }
    }
    return EChange.UNCHANGED;
  }
1252222
public function validatePayment()
    {
        // Remove payment methods initialization data from session of any is set
        $this->_unsetSessionInitData();

        $mReturn = $this->_OxpsPaymorrowPayment_validatePayment_parent();

        if ($this->_isPaymorrowPayment(oxRegistry::getConfig()->getRequestParameter('paymentid')) and
            $this->_isPaymentResponseSessionInvalid()
        ) {
            oxRegistry::getSession()->setVariable('payerror', 1);

            return null;
        }

        return $mReturn;
    }
747701
protected function getPointConverter(Session $session)
    {
        if ($this->point_converter === null) {
            $this->point_converter = $session
                ->getClientUsingPooler('converter', 'point');
        }

        return $this->point_converter;
    }
78739
public function offsetGet($offset)
    {
        if (!isset($this->session[$this->prefix][$offset])) {
            return null;
        }

        $result = $this->session[$this->prefix][$offset];
        unset($this->session[$this->prefix][$offset]);

        return $result;
    }
1352906
public function session($name = null, $default = null) {
        if (null === $name) {
            return $_SESSION;
        }
        if (isset($_SESSION[$name])) {
            return $_SESSION[$name];
        }
        return $default;
    }
1224273
private static function session($session)
    {
        $files = ['Session'];
        $folder = static::$root.'Storage'.'/';

        self::call($files, $folder);

        $files = ['SessionKeyNotFoundException', 'SessionSurfaceIsOffException'];
        $folder = static::$root.'Storage/Exceptions'.'/';

        self::call($files, $folder);

        //Initiat the class
        if ($session) {
            Session::ini();
        }
    }
856732
public static function initialize(Session $session) : void
    {
        static::$_session = $session;

        if(!static::$_session->keyExists("_RESULTS")) {
            static::$_session->set("_RESULTS", []);
        }
    }