Get CSRF cookie value

@return string
@throws SecureRequestHelper\CSRFException Thrown if the CSRF layer has not been initialized
7619
public function getCSRFCookie()
	{
		$cookie = $this->_browserInterface->getCookie($this->_csrf_cookiename);
		if ( !$cookie )
			throw new SecureRequestHelper\CSRFException('CSRF cookie has not been initialized');
		
		return $cookie;
	}
1325172
public function getValue()
    {

        $value = $this->defaultValue;
        if ($this->existsRequest()) {
            $value = trim($_GET[$this->requestName]);
        }

        return $value;

    }
701275
protected function getCookies() 
    {
        $headers = '';
        foreach ($this->cookies as $key => $val) {
            if ($headers) $headers .= '; ';
            $headers .= $key. '='. $val;
        }

        if ($headers) {
            $headers = "Cookie: $headers"."\r\n";
        }

        return $headers;
    }
1156521
public function getFromCookie()
    {
        $varName = $this->getCurrentVarName();
        if (isset($_COOKIE[$varName])) {
            $recordId = $_COOKIE[$varName];

            $item = $this->findOne(intval($recordId));
            if ($item) {
                return $item;
            }
        }

        return false;
    }
40488
private function read()
    {
        if ($this->request->hasParam($this->sessionName)) {
            return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
        } elseif ($this->request->hasCookie($this->sessionName)) {
            return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
        }

        return null;
    }
1365721
public function getSignedRequest() {
    if (!$this->signedRequest) {
      if (!empty($_REQUEST['signed_request'])) {
        $this->signedRequest = $this->parseSignedRequest(
          $_REQUEST['signed_request']);
      } else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) {
        $this->signedRequest = $this->parseSignedRequest(
          $_COOKIE[$this->getSignedRequestCookieName()]);
      }
    }
    return $this->signedRequest;
  }
518129
public static function getCSRFToken() {
        $allHeaders = array_change_key_case(parent::getHeaders(), CASE_UPPER);

        if (array_key_exists('X-CSRF-TOKEN', $allHeaders)) {
            return $allHeaders['X-CSRF-TOKEN'];
        } else {
            throw new \Exception(ExceptionMessages::CSRF_TOKEN_NOT_FOUND);
        }
    }
800021
protected function _get_cookie()
	 {
		// was the cookie value posted?
		$cookie = \Input::post($this->config['post_cookie_name'], false);

		// if not found, fetch the regular cookie
		if ($cookie === false)
		{
			$cookie = \Cookie::get($this->config['cookie_name'], false);
		}

		// if not found, was a session-id present in the HTTP header?
		if ($cookie === false)
		{
			$cookie = \Input::headers($this->config['http_header_name'], false);
		}

		// if not found, check the URL for a cookie
		if ($cookie === false)
		{
			$cookie = \Input::get($this->config['cookie_name'], false);
		}

		if ($cookie !== false)
		{
			// fetch the payload
			$this->config['encrypt_cookie'] and $cookie = \Crypt::decode($cookie);
			$cookie = $this->_unserialize($cookie);

			// validate the cookie format: must be an array
			if (is_array($cookie))
			{
				// cookies use nested arrays, other drivers have a string value
				if (($this->config['driver'] === 'cookie' and ! is_array($cookie[0])) or
					($this->config['driver'] !== 'cookie' and ! is_string($cookie[0])))
				{
					// invalid specific format
					logger('DEBUG', 'Error: Invalid session cookie specific format');
					$cookie = false;
				}
			}

			// or a string containing the session id
			elseif (is_string($cookie) and strlen($cookie) == 32)
			{
				$cookie = array($cookie);
			}

			// invalid general format
			else
			{
				logger('DEBUG', 'Error: Invalid session cookie general format');
				$cookie = false;
			}
		}

		// and the result
		return $cookie;
	 }
1091458
protected function generateCsrfToken()
    {
        $token = $this->app->getSecurity()->generateRandomString();
        if ($this->enableCsrfCookie) {
            $cookie = $this->createCsrfCookie($token);
            $this->app->getResponse()->getCookies()->add($cookie);
        } else {
            $this->app->getSession()->set($this->csrfParam, $token);
        }

        return $token;
    }
244063
public function getVisitorIdForThirdPartyCookie()
    {
        $found = false;

        // For 3rd party cookies, priority is on re-using the existing 3rd party cookie value
        if (!$found) {
            $useThirdPartyCookie = $this->shouldUseThirdPartyCookie();
            if ($useThirdPartyCookie) {
                $idVisitor = $this->getThirdPartyCookieVisitorId();
                if(!empty($idVisitor)) {
                    $found = true;
                }
            }
        }

        // If a third party cookie was not found, we default to the first party cookie
        if (!$found) {
            $idVisitor = Common::getRequestVar('_id', '', 'string', $this->params);
            $found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING;
        }

        if ($found) {
            return $this->getVisitorIdAsBinary($idVisitor);
        }

        return false;
    }
486924
protected function parseCookies ()
    {
        $cookie = '';

        foreach( $this->cookies as $name => $value )
            $cookie .= $name . '=' . $value . '; ';

        return rtrim( $cookie, ';' );
    }
1250601
public function value()
    {
        if (strtolower($this->name()) === 'set-cookie') {
            return join("\r\n" . $this->name() . ': ', $this->data());
        } else {
            return join(', ', $this->_data);
        }
    }
487744
public function csrf_verify() {
		// If no POST data exists we will set the CSRF cookie
		if (count($_POST) == 0) {
			return $this->csrf_set_cookie();
		}
		
		// Do the tokens exist in both the _POST and _COOKIE arrays?
		if (!isset($_POST[$this->_csrf_token_name]) or !isset($_COOKIE[$this->_csrf_cookie_name])) {
			$this->csrf_show_error();
		}
		
		// Do the tokens match?
		if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name]) {
			$this->csrf_show_error();
		}
		
		// We kill this since we're done and we don't want to
		// polute the _POST array
		unset($_POST[$this->_csrf_token_name]);
		
		// Nothing should last forever
		unset($_COOKIE[$this->_csrf_cookie_name]);
		$this->_csrf_set_hash();
		$this->csrf_set_cookie();
		
		//log_message('debug', "CSRF token verified ");
		
		return $this;
	}
60660
private function checkCsrfToken() {

		$tokenManager = new CsrfTokenManager();

		$token = new CsrfToken(
			'_' . $this->action . '_',
			$this->requestValues->get(self::CSRF_TOKEN_NAME)
		);

		return $tokenManager->isTokenValid($token);

	}
16201
public static function get() : array
  {
    return [
      'csrf_token' => CSRF::generate(),
      'errors' => Variable::has('validation.errors') ? Variable::get('validation.errors') : (new ValidatorFactory())->make([], [])->errors(),
      'old' => Variable::has('form.old') ? Variable::get('form.old') : [],
    ];
  }
527767
public function getCookieStr()
    {
        $cookie = '';
        foreach ($this->getCookies() as $co => $vo) {
            if (strtoupper($vo) != 'EXPIRED') {
                $cookie .= $co . '=' . $vo . ';';
            }
        }
        return $cookie;
    }
884020
public function csrf_set_cookie() {
		$expire = time() + $this->_csrf_expire;
		$secure_cookie = (Cfg::get('cookie.secure') === TRUE) ? 1 : 0;
		
		if ($secure_cookie) {
			$req = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : FALSE;
			
			if (!$req or $req == 'off') {
				return FALSE;
			}
		}
		
		setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, Cfg::get('cookie.path'), Cfg::get('cookie.domain'), $secure_cookie);
		
		//log_message('debug', "CRSF cookie Set");
		
		return $this;
	}