Set all cookies found in the given array.

@param array<string, mixed> $cookies
@return HttpRequest
542150
public function setCookies(array $cookies)
	{
		$this->cookies = [];
		
		foreach($cookies as $name => $value)
		{
			$this->setCookie($name, $value);
		}
		
		return $this;
	}
107685
public void setCookies(List<HttpCookie> cookies) {
        if (cookies.isEmpty()) {
            setHeader(HttpHeader.COOKIE, null);
        }

        StringBuilder sbData = new StringBuilder();

        for (HttpCookie c : cookies) {
            sbData.append(c.getName());
            sbData.append('=');
            sbData.append(c.getValue());
            sbData.append("; ");
        }

        if (sbData.length() <= 3) {
            setHeader(HttpHeader.COOKIE, null);
            return;
        }

        final String data = sbData.substring(0, sbData.length() - 2);
        setHeader(HttpHeader.COOKIE, data);
    }
347306
public function createCookie($cookie = true)
    {
        if ($cookie) {
            $cookietime = time() + (60 * 60 * 24 * 365);
            setcookie($this->_sessionName . "_SessionID", $this->_session->SessionID, $cookietime);
            setcookie($this->_sessionName . "_Timestamp", $this->_session->Timestamp, $cookietime);
        }

        return $this;
    }
1319179
public function cookie(string $name, $value): HttpRequest
    {
        if ($name != 'Array') {
            $this->cookies[$name] = $value;
        }
        return $this;
    }
636390
protected function setCookieInResponse(Cookie $cookie)
    {
        $method = $cookie->isRaw() ? 'rawcookie' : 'cookie';

        $this->response->$method(
            $cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(),
            $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()
        );
    }
466983
protected function checkCookies(array $cookies)
    {
        foreach ($cookies as $index => $cookie) {
            if (!$cookie instanceof CookieInterface) {
                throw new InvalidArgumentException(
                    sprintf(
                        'Expected `%s[]` as $cookies but instead got `%s` at index %d',
                        static::class,
                        getTypeName($cookie),
                        $index
                    )
                );
            }
        }
    }
1160984
public String setCookie(final String cookie) {
        final String prev = this.cookie;
        this.cookie = cookie;
        return prev;
    }
74522
public function addCookie($cookie)
    {
        if (is_array($cookie)) {
            $cookie = Cookie::createFromArray($cookie);
        }
        if (!$cookie instanceof Cookie) {
            throw new InvalidArgumentException('Cookie must be set from instance of Cookie class or from array.');
        }

        $this->executor->execute(
            DriverCommand::ADD_COOKIE,
            ['cookie' => $cookie->toArray()]
        );

        return $this;
    }
799412
public function addCookie(Cookie $cookie) : self
    {
        if (isset($this->cookies[$cookie->getName()])) {
            throw new \InvalidArgumentException(sprintf("Cookie '%s' is already set", $cookie->getName()));
        }

        $this->cookies[$cookie->getName()] = $cookie;

        return $this;
    }
934605
public static function fromArray(array $cookies, $domain)
    {
        $cookieJar = new self();
        foreach ($cookies as $name => $value) {
            $cookieJar->setCookie(new SetCookie([
                'Domain'  => $domain,
                'Name'    => $name,
                'Value'   => $value,
                'Discard' => true
            ]));
        }

        return $cookieJar;
    }
1287773
public function add($cookie, array $default = [], bool $nonempty = false): Cookies
    {
        if (!$cookie instanceof Cookie) {
            $cookie = new Cookie($cookie, $default);
        }
        //只允许非空cookie
        if ($nonempty && $cookie->value === '') {
            return $this;
        }

        // php array is a natural high-performance hash table
        // According to chrome's handling, path is only used as a cookie attribute, and the same domain+name is treated as the same cookie.
        $key = $cookie->domain . self::DELIMITER . $cookie->name;
        if (isset($this->raw[$key])) {
            //重置排序(tip:这会消耗很多性能)
            unset($this->raw[$key]);
        }
        $this->raw[$key] = $cookie;

        return $this;
    }
987262
public function addCookie(Cookie $cookie): Response
    {
        $this->cookies[$cookie->name()] = $cookie;
        return $this;
    }
402063
protected static function buildCookieHeader($cookies)
    {
        $headers = [];
        foreach ($cookies as $cookie) {
            $parts = [
                sprintf('%s=%s', urlencode($cookie['name']), urlencode($cookie['value']))
            ];
            if ($cookie['expire']) {
                $cookie['expire'] = gmdate('D, d M Y H:i:s T', $cookie['expire']);
            }
            $attributes = [
                'expire' => 'Expires=%s',
                'path' => 'Path=%s',
                'domain' => 'Domain=%s',
                'httpOnly' => 'HttpOnly',
                'secure' => 'Secure',
            ];
            foreach ($attributes as $key => $attr) {
                if ($cookie[$key]) {
                    $parts[] = sprintf($attr, $cookie[$key]);
                }
            }
            $headers[] = implode('; ', $parts);
        }

        return $headers;
    }
31010
public function setCookie(ResponseCookie $cookie)
    {
        $this->cookies[$cookie->getName()] = $cookie;
        $this->setHeadersFromCookies();
    }
165968
public function setCookie(CookieJar $cookie)
    {
        return $this->getCache()->save($this->getCacheKey(), $cookie, Config::get('cache.expire', 100));
    }
188971
public function with_cookie( $cookie ) {
		if ( is_string( $cookie ) ) {
			$cookie = call_user_func_array( [ $this, 'create_cookie' ], func_get_args() );
		}

		$this->headers->setCookie( $cookie );

		return $this;
	}
148333
public function applyCookies($cookies)
    {
        $values = [];
        foreach ($cookies as $cookie) {
            if ($cookie->matches($this->url())) {
                $values[$cookie->path()] = $cookie->name() . '=' . $cookie->value();
            }
        }

        $keys = array_map('strlen', array_keys($values));
        array_multisort($keys, SORT_DESC, $values);
        $headers = $this->headers();
        if ($values) {
            $headers['Cookie'] = implode('; ', $values);
        } else {
            unset($headers['Cookie']);
        }
        return $this;
    }