Validate CSRF token from current request
against token value stored in $_SESSION

@param  string $name  CSRF name
@param  string $value CSRF token value

@return bool
431122
protected function validateToken($name, $value)
    {
        $token = $this->getFromStorage($name);
        if (function_exists('hash_equals')) {
            $result = ($token !== false && hash_equals($token, $value));
        } else {
            $result = ($token !== false && $token === $value);
        }
        $this->removeFromStorage($name);

        return $result;
    }
1210403
public function isValid($value, $context = null) {
        $frontController = \Zend_Controller_Front::getInstance();
        $request = $frontController->getRequest();
        $value = $request->getParam('g-recaptcha-response');
        if (empty($value)) {
            $this->_error(self::CAPTCHA_EMPTY);
            return false;
        }
        $this->_value = $value;

        if (!$this->_verify($value)) {
            $this->_error(self::INVALID_CAPTCHA);
            return false;
        }

        return true;
    }
965184
public function get($name, $value = '')
    {
        if ($this->has($name)) {
            if($this->app->config('session.encryption')) {
                return $_SESSION[$name] ? $this->encrypter->decrypt($_SESSION[$name]) : $value;
            } else {
                return $_SESSION[$name] ? $_SESSION[$name] : $value;
            }
        }

        if (!empty($value)) {
            return $value;
        }

        return null;
    }
737155
public function responseHeaderEquals($name, $value)
    {
        $actual = $this->session->getResponseHeader($name);
        $message = sprintf('Current response header "%s" is "%s", but "%s" expected.', $name, $actual, $value);

        $this->assert($value === $actual, $message);
    }
864359
public function isValid($value, $context = null) {
        $this->_setValue((string) $value);

        $token = $this->getToken();
        $pos = strrpos($token, '[');
        if ($pos !== false) {
            $token = rtrim($token, ']');
            $token = substr($token, $pos+1);
        }

        if (($context !== null) && isset($context) && array_key_exists($token, $context)) {
            $token = $context[$token];
        }

        if ($token === null) {
            $this->_error(self::MISSING_TOKEN);
            return false;
        }

        $strict = $this->getStrict();
        if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
            $this->_error(self::NOT_SAME);
            return false;
        }

        return true;
    }
658166
protected function validateCsrfToken($value = null, $id = 'bolt')
    {
        if (!$this->isCsrfTokenValid($value, $id)) {
            $this->abort(Response::HTTP_BAD_REQUEST, Trans::__('general.phrase.something-went-wrong'));
        }
    }
545870
public function isTokenValid($value)
    {
        $csrfToken = new CsrfToken($this->tokenId, $value);

        return $this->csrfTokenManager->isTokenValid($csrfToken);
    }
570914
public function create($name, $value = '')
    {
        $_SESSION[$name] = $value;

        if(isset($_SESSION[$name])) {

            return true;
        }

        return false;
    }
957111
protected function checkCsrf($id = 'lexik-translation', $query = '_token')
    {
        if (!$this->has('security.csrf.token_manager')) {
            return;
        }

        $request = $this->get('request_stack')->getCurrentRequest();

        if (!$this->isCsrfTokenValid($id, $request->get($query))) {
            throw $this->createAccessDeniedException('Invalid CSRF token');
        }
    }
1118156
private function validate(ServerRequestInterface $request, string $tokenValue): bool
    {
        // Validate POST, PUT, DELETE, PATCH requests
        $method = $request->getMethod();
        if (!in_array($method, ['POST', 'PUT', 'DELETE', 'PATCH'])) {
            return true;
        }

        $postData = $request->getParsedBody();

        $requestCsrfToken = null;
        if (isset($postData[$this->name])) {
            $requestCsrfToken = $postData[$this->name];
        }
        if (!$requestCsrfToken) {
            // Reads the value and adds it to the request as the X-XSRF-TOKEN header.
            $headers = $request->getHeader('X-CSRF-Token');
            $requestCsrfToken = reset($headers);
        }

        if ($requestCsrfToken !== $tokenValue) {
            throw new RuntimeException('CSRF middleware failed. Invalid CSRF token. This looks like a cross-site request forgery.');
        }

        return true;
    }
1000632
public function validateToken()
	{
		if ($this->token !== $this->getToken())
		{
			// Using 'public' as the session ID allows for shareable URLs
			// not tied to a specific user session. Usage would be for
			// files that do not need access control.
			$this->session_id = 'public';
		}
		return ($this->token === $this->getToken());
	}
666501
private function validate(string $name, $value): bool
    {
        if (! isset($this->validators[$name])) {
            return true;
        }

        $errors = [];

        $isValid = true;
        foreach ($this->validators[$name] as $validator) {
            if (! $validator->is_valid($value)) {
                $errors = array_merge($errors, $validator->get_error_messages());
                $isValid = false;
            }
        }

        $element = $this->element($name);
        if ($element instanceof ErrorAwareInterface) {
            $element->withErrors($errors);
        }

        return $isValid;
    }
511779
public function initialize($csrf = false)
    {
        $this->_tokenRequired = $csrf;
        if ($csrf) {
            // get current token value from session
            $currentToken = App::$Session->get('_csrf_token', false);
            // set new token value to session
            $newToken = Crypt::randomString(mt_rand(32, 64));
            App::$Session->set('_csrf_token', $newToken);
            // if request is submited for this model - try to validate input data
            if ($this->send()) {
                // token is wrong - update bool state
                if ($currentToken !== $this->getRequest('_csrf_token')) {
                    $this->_tokenOk = false;
                }
            }
            // set token data to display
            $this->_csrf_token = $newToken;
        }
    }
1269824
public static function request($name)
    {
        if (app()->config->get('request.csrf')) {
            $name = self::hash($name);
        }

        return $name;
    }
339582
static function validate($name,$token){
        if(isset($_SESSION['_hiano_token'][$name])){
            $ret =  $_SESSION['_hiano_token'][$name] == $token;
            unset($_SESSION['_hiano_token'][$name]);
            return $ret;
        }
        return false;
    }
1254158
public function responseHeaderContains($name, $value)
    {
        $actual = $this->session->getResponseHeader($name);
        $message = sprintf('The text "%s" was not found anywhere in the "%s" response header.', $value, $name);

        $this->assert(false !== stripos($actual, $value), $message);
    }
946749
protected function validateConfig($name, $value)
	{
		switch ($name)
		{
			case 'offset':
			case 'totalItems':
				// make sure it's an integer
				if ($value != intval($value))
				{
					$value = 0;
				}
				// and that it's within bounds
				$value = max(0, $value);
			break;

			// validate integer values
			case 'current':
			case 'limit':
			case 'totalPages':
			case 'numberOfLinks':
			case 'uriSegment':
				// make sure it's an integer
				if ($value != intval($value))
				{
					$value = 1;
				}
				// and that it's within bounds
				$value = max(1, $value);
			break;

			// validate booleans
			case 'showFirst':
			case 'showLast':
				if ( ! is_bool($value))
				{
					$value = (bool) $value;
				}
			break;

			// possible alignment values
			case 'align':
				if ( ! in_array($value = strtolower($value), array('left', 'center', 'right')))
				{
					$value = 'center';
				}
			break;

			// validate the link offset, and adjust if needed
			case 'linkOffset':
				// make sure we have a fraction between 0 and 1
				if ($value > 1)
				{
					$value = $value / 100;
				}

				// and that it's within bounds
				$value = max(0.01, min($value, 0.99));
			break;
		}

		return $value;
	}