Asserts that the response contains the given cookie and equals the optional value.

@param  string  $cookieName
@param  mixed  $value
@param  bool  $encrypted
@param  bool  $unserialize
@return $this
484651
protected function seeCookie($cookieName, $value = null, $encrypted = true, $unserialize = true)
    {
        $headers = $this->response->headers;

        $exist = false;

        foreach ($headers->getCookies() as $cookie) {
            if ($cookie->getName() === $cookieName) {
                $exist = true;
                break;
            }
        }

        $this->assertTrue($exist, "Cookie [{$cookieName}] not present on response.");

        if (! $exist || is_null($value)) {
            return $this;
        }

        $cookieValue = $cookie->getValue();

        $actual = $encrypted
            ? $this->app['encrypter']->decrypt($cookieValue, $unserialize) : $cookieValue;

        $this->assertEquals(
            $actual, $value,
            "Cookie [{$cookieName}] was found, but value [{$actual}] does not match [{$value}]."
        );

        return $this;
    }
631796
public function setAdditionalCookie($cookie, $expectedValue = false)
    {
        $additionalCookie = $this->_getData('_additional_cookie');
        if (!$additionalCookie || !is_array($additionalCookie)) {
            $additionalCookie = array();
        }

        $additionalCookie[$cookie] = $expectedValue;
        $this->setData('_additional_cookie', $additionalCookie);
        return $this;
    }
816413
public function unserialize($serialized)
    {
        $data = Json::decode($serialized);

        foreach (['token', 'cookie_token'] as $key) {
            if (!array_key_exists($key, $data)) {
                throw new SecurityException("Unserialized CSRF token doesn't contain required \"{$key}\" key");
            }
        }

        $this->token = $data['token'];
        $this->cookieToken = $data['cookie_token'];
    }
236115
public static function send_cookie(
		$name, $value='', $expire=0, $path='', $domain='',
		$secure=false, $httponly=false
	) {
		if (!isset($_COOKIE))
			$_COOKIE = [];
		if ($expire > 0) {
			$_COOKIE[$name] = $value;
			return;
		}
		if (isset($_COOKIE[$name]))
			unset($_COOKIE[$name]);
	}
1236706
public final function cookie(string $name, string $value = null)
    {
        return ($value === null) ? $this->getCookie($name) : $this->setCookie($name, $value);
    }
1100105
public function withCookie($key, $value, $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false)
    {
        $self = clone $this;
        $self->cookies[] = [
            'key'       => $key,
            'value'     => $value,
            'expire'    => $expire,
            'path'      => $path,
            'domain'    => $domain,
            'secure'    => $secure,
            'httponly'  => $httponly,
        ];
        return $self;
    }
196106
public function setCookie($name, $value = null, $expire = null,
                              $domainPath = null, $https = null, $httpOnly = null)
    {
        if (!$this->response) {
            return $this->getResponse()->setCookie($name, $value, $expire, $domainPath, $https, $httpOnly);
        }
        return parent::setCookie($name, $value, $expire, $domainPath, $https, $httpOnly);
    }
412013
public static function put($name, $value, $expiration = 0, $path = '/', $domain = null, $secure = false)
    {
        if ($expiration !== 0) {
            $expiration = time() + ($expiration * 60);
        }

        $value = static::hash($value) . '+' . $value;

        // are we attempting to send a secure cookie over the insecure HTTP.
        if ($secure === true && Config::get('ssl') === false) {
            throw new \RuntimeException("Attempting to set secure cookie over HTTP!");
        }

        static::$jar[$name] = compact('name', 'value', 'expiration', 'path', 'domain', 'secure');

        return true;
    }
550960
protected function _decode($value, $encrypt, $key)
    {
        if (!$encrypt) {
            return $this->_explode($value);
        }
        $this->_checkCipher($encrypt);
        $prefix = 'Q2FrZQ==.';
        $prefixLength = strlen($prefix);

        if (strncmp($value, $prefix, $prefixLength) !== 0) {
            return '';
        }

        $value = base64_decode(substr($value, $prefixLength), true);

        if ($value === false || $value === '') {
            return '';
        }

        if ($key === null) {
            $key = $this->_getCookieEncryptionKey();
        }
        if ($encrypt === 'rijndael') {
            $value = Security::rijndael($value, $key, 'decrypt');
        }
        if ($encrypt === 'aes') {
            $value = Security::decrypt($value, $key);
        }

        if ($value === false) {
            return '';
        }

        return $this->_explode($value);
    }
262119
public static function set($name, $value, $expire = 0, $path = '/', $domain = '', $secure = '')
	{
		if(!self::$isInit)
		{
			self::init();
		}
		return setcookie($name, $value, is_numeric($expire) ? $expire : self::$expire, '' == $path ? self::$path : $path, '' == $domain ? self::$domain : $domain, '' == $secure ? self::$secure : $secure);
	}
1167368
public static function set($name, $value = '', $expire = 0)
    {
        !isset(self::$init) && self::init();

        if ($expire !== 0) {
            $expire = !empty(self::$config['expire']) ? $_SERVER['REQUEST_TIME'] + intval(self::$config['expire']) : 0;
        }

        if (is_string($name)) {
            setcookie(
                $name, $value, $expire, self::$config['path'],
                self::$config['domain'], self::$config['secure']
            );
        }

        if (is_array($name)) {
            foreach ($name as $item => $val) {
                setcookie(
                    $name, $val, $expire, self::$config['path'],
                    self::$config['domain'], self::$config['secure']
                );
            }
        }
    }
538246
public function getCookie($cookieName) {
        if (isset($_COOKIE[$cookieName])) {
            return $this->decodeCookie($_COOKIE[$cookieName]);
        } else {
            return false;
        }
    }
480523
public function setCookies($cookiedomain, $cookiepath, $expires=0, $secure=0, $httponly=1)
	{
		$cookies = $this->parsecookies($this->cookies);
		foreach ($cookies as $cookie) {
			$name = '';
			$value = '';
			if ($expires == 0) {
				$expires_time = 0;
			} else {
				$expires_time = time()+$expires;
			}
			if (isset($cookie['value']['key'])) {
				$name = $cookie['value']['key'];
			}
			if (isset($cookie['value']['value'])) {
				$value = $cookie['value']['value'];
			}
			if (isset($cookie['expires'])) {
				$expires_time = $cookie['expires'];
			}
			if (!$cookiepath) {
				if (isset($cookie['path'])) {
					$cookiepath = $cookie['path'];
				}
			}
			if (!$cookiedomain) {
				if (isset($cookie['domain'])) {
					$cookiedomain = $cookie['domain'];
				}
			}
			$this->status['debug'][] = $this->addCookie($name, urldecode($value), $expires_time, $cookiepath, $cookiedomain, $secure, $httponly);
			if ($name == 'MOODLEID_') {
				$this->status['cURL']['moodle'] = urldecode($value);
			}
		}
		return $this->status;
	}
1309702
public static function set(
        $name,
        $value,
        $expiry = 90,
        $path = null,
        $domain = null,
        $secure = false,
        $httpOnly = true
    ) {
        return self::get_inst()->set($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
    }
876664
public function setSecureCookie(
        $name = "",
        $value = "",
        $expire = 0,
        $path = "/",
        $domain = "",
        $secure = false,
        $httpOnly = false
    ) {
        Cookies::$plugin->cookies->setSecure(
            $name,
            $value,
            $expire,
            $path,
            $domain,
            $secure,
            $httpOnly
        );
    }
662373
public function setCookie(
        $name = "",
        $value = "",
        $expire = 0,
        $path = "/",
        $domain = "",
        $secure = false,
        $httpOnly = false
    ) {
        Cookies::$plugin->cookies->set(
            $name,
            $value,
            $expire,
            $path,
            $domain,
            $secure,
            $httpOnly
        );
    }
31310
public function cookie($name, $value, $expires = 0, $path = '', $domain = '', $secure = false, $httpOnly = false)
    {
        $cookie = new Cookie(
            $name,
            $value,
            $expires
        );

        return $cookie
            ->setPath($path)
            ->setDomain($domain)
            ->setIsSecure($secure)
            ->setIsHttpOnly($httpOnly)
            ->commit();
    }