Add a cookie.

@param KHttpCookie $cookie
13934
public function addCookie(KHttpCookie $cookie)
    {
        $this->_cookies[$cookie->domain][(string) $cookie->path][$cookie->name] = $cookie;
    }
31010
public function setCookie(ResponseCookie $cookie)
    {
        $this->cookies[$cookie->getName()] = $cookie;
        $this->setHeadersFromCookies();
    }
851784
public function setCookie($key, $value)
    {
        $this->cookies[$key] = $value;
        $this->setOpt(CURLOPT_COOKIE, str_replace('+', '%20', http_build_query($this->cookies, '', '; ')));
    }
419584
protected function setCookie($cookie)
    {
        $this->cookie = trim(base64_encode(mcrypt_encrypt(
            MCRYPT_RIJNDAEL_256, '7e2d20j23a21db9f', $cookie, MCRYPT_MODE_ECB, $this->config->getSecret()
        )));

        setcookie($this->config->getCookieName(), $this->cookie, (time() + 60 * 5), null, null, null, true);

        return $this;
    }
533069
public void setCookies(List<HttpCookie> cookies) {
		Map<String, HttpCookie> map = new HashMap<String, HttpCookie>();
		for (HttpCookie cookie : cookies) {
			map.put(cookie.getName(), cookie);
		}
		this.cookies = map;
	}
571977
public HttpResponse addCookie(Collection<HttpCookie> cookies) {
        this.cookies = Utility.append(this.cookies, cookies);
        return this;
    }
64701
public function addCookie(CookieInterface $cookie)
    {

        // check if this cookie has already been set
        if ($this->hasCookie($name = $cookie->getName())) {
            // then check if we've already one cookie header available
            if (is_array($cookieValue = $this->getCookie($name))) {
                $cookieValue[] = $cookie;
            } else {
                $cookieValue = array($cookieValue, $cookie);
            }

            // add the cookie array
            $this->cookies[$name] = $cookieValue;

        } else {
            // when add it the first time, simply add it
            $this->cookies[$name] = $cookie;
        }
    }
416945
public Response andCookie(Cookie cookie) {
        Objects.requireNonNull(cookie, Required.COOKIE.toString());
        this.cookies.add(cookie);

        return this;
    }
714062
public function addCookie(CookieInterface $cookie)
    {
        if (!$cookie->getDomain() || !$cookie->getPath()) {
            throw new InvalidArgumentException('Cookie must have a domain and a path set.');
        }
        $this->_cookies = $this->_cookies->add($cookie);

        return $this;
    }
1160984
public String setCookie(final String cookie) {
        final String prev = this.cookie;
        this.cookie = cookie;
        return prev;
    }
950329
@Override
    public void addCookie(Cookie cookie) {

        if (cookie == null) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_ADD_COOKIE_0));
        }

        StringBuffer header = new StringBuffer(128);

        // name and value
        header.append(cookie.getName());
        header.append('=');
        header.append(cookie.getValue());

        // add version 1 / RFC 2109 specific information
        if (cookie.getVersion() == 1) {
            header.append("; Version=1");

            // comment
            if (cookie.getComment() != null) {
                header.append("; Comment=");
                header.append(cookie.getComment());
            }
        }

        // domain
        if (cookie.getDomain() != null) {
            header.append("; Domain=");
            header.append(cookie.getDomain());
        }

        // max-age / expires
        if (cookie.getMaxAge() >= 0) {
            if (cookie.getVersion() == 0) {
                // old Netscape format
                header.append("; Expires=");
                long time;
                if (cookie.getMaxAge() == 0) {
                    time = 10000L;
                } else {
                    time = System.currentTimeMillis() + (cookie.getMaxAge() * 1000L);
                }
                header.append(CmsDateUtil.getOldCookieDate(time));
            } else {
                // new RFC 2109 format
                header.append("; Max-Age=");
                header.append(cookie.getMaxAge());
            }
        }

        // path
        if (cookie.getPath() != null) {
            header.append("; Path=");
            header.append(cookie.getPath());
        }

        // secure
        if (cookie.getSecure()) {
            header.append("; Secure");
        }

        addHeader("Set-Cookie", header.toString());
    }
372692
protected function persistCookies(array $cookies)
    {
        $cookieFileName = $this->getCookieFileName();
        $contents = <<<EOT
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

EOT;

        foreach ($cookies as $cookie) {
            $contents .= implode(TAB, $cookie) . LF;
        }

        file_put_contents($cookieFileName, $contents);
    }
457438
public void add(final URI uri, final HttpCookie cookie) {
        if(cookie.getMaxAge() == 0) {
            return;
        }

        if(cookie.getDomain() != null) {
            add(new DomainKey(cookie), cookie);
        }
        
        if(uri != null) {
            add(new UriKey(uri, cookie), cookie);
        }
    }
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;
    }
1110402
function(res) {
  function addCookie(cookie) {
    try {
      cookieJar.setCookieSync(cookie, config.base_url);
    } catch (err) {
      throw err;
    }
  }

  if (Array.isArray(res.headers['set-cookie'])) {
    res.headers['set-cookie'].forEach(addCookie);
  } else {
    addCookie(res.headers['set-cookie']);
  }
}
1045946
public function sendCookies(): void
    {
        foreach ((array) $this->cookies as $cookie) {
            $this->sendCookie($cookie['name'], $cookie['value'], $cookie['expire'],
                $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']);
        }
    }
1009975
public function add(Cookie $cookie)
    {
        if ($cookie instanceof MutableCookie) {
            $this->cookies[$cookie->getName()] = $cookie;
        } elseif ($cookie instanceof ResponseCookie) {
            $this[$cookie->getName()]->set($cookie->get())
                ->setPath($cookie->getPath())
                ->setDomain($cookie->getDomain())
                ->setSecure($cookie->isSecure())
                ->setHttpOnly($cookie->isHttpOnly())
                ->expiresAt($cookie->getExpiration());
        } else {
            $this->cookies[$cookie->getName()] = $this->setDefaults(
                new MutableCookie($cookie->getName(), $cookie->get())
            );
        }
    }