Set new cookies

@param CookieJar $cookie

@return bool
165968
public function setCookie(CookieJar $cookie)
    {
        return $this->getCache()->save($this->getCacheKey(), $cookie, Config::get('cache.expire', 100));
    }
403539
public function setCookies($cookies = [])
    {
        if (!is_array($cookies)) {
            $this->cookies = [];
        } else {
            $this->cookies      = $cookies;
            $this->trackCookies = TRUE;
        }
    }
885075
public void setCookies(final Cookie[] cookies) {
        this.cookies.clear();
        if (cookies != null) {
            for (final Cookie cookie : cookies) {
                cookie(cookie);
            }
        }
    }
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;
    }
605641
public function del($cookie) {

        if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name");

        $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie;

        if ( $this->isRegistered($name) ) {
            unset($this->cookies[$name]);
        } else {
            throw new CookieException("Cookie is not registered");
        }

        return $this;

    }
308209
public function setCookies($cookies)
    {
        if (!$cookies instanceof CookieBag) {
            $cookies = new CookieBag(CookieBag::normalize($cookies));
        }

        $this->_cookies = $cookies;
    }
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;
    }
549406
def update(self, cookies):
    
    cookie_jar = self.get_cookie_jar()
    for cookie in cookies:
      cookie_jar.set_cookie(cookie)
    with self._lock:
      cookie_jar.save()
680097
function setAllCookies(array $cookies)
    {
        // Must do this for PHP 5.3 compat.
        $cookies_max_age = $this->cookies_max_age;
        $this->cookievars = array_map(
            function($cookieval) use ($cookies_max_age) {
                return array(
                    'value' => $cookieval,
                    'max_age' => $cookies_max_age,
                );
            },
            $cookies
        );
        return $this;
    }
1225165
public function setCookie($cookies = [])
    {
        $this->cookies = $cookies;
        $this->debug->info(__FUNCTION__, 'setCookie: ', $this->cookies);

        return $this;
    }
947319
public function has($cookie) {

        if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name");

        $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie;

        return array_key_exists($name, $this->cookies);

    }
153300
public function add($cookie)
    {
        // If the name string is empty (but not 0), ignore the set-cookie
        // string entirely.
        $name = $cookie->name();

        if (!$name && $name !== '0') {
            return false;
        }

        // Only allow cookies with set and valid domain, name, value
        $result = $cookie->isValid();
        if ($result !== true) {
            if ($this->_strictMode) {
                throw new RuntimeException('Invalid cookie: ' . $result);
            } else {
                $cookieValue = $cookie->value();
                if ($cookieValue === null || $cookieValue === '') {
                    $this->clear($cookie->domain(), $cookie->path(), $cookie->name());
                }
                return false;
            }
        }

        // Resolve conflicts with previously set cookies
        foreach ($this->_data as $i => $c) {

            // Two cookies are identical, when their path, and domain are
            // identical.
            if ($c->path() != $cookie->path() ||
                $c->domain() != $cookie->domain() ||
                $c->name() != $cookie->name()
            ) {
                continue;
            }

            // The previously set cookie is a discard cookie and this one is
            // not so allow the new cookie to be set
            if (!$cookie->discard() && $c->discard()) {
                unset($this->_data[$i]);
                continue;
            }

            // If the new cookie's expiration is further into the future, then
            // replace the old cookie
            if ($cookie->expires() > $c->expires()) {
                unset($this->_data[$i]);
                continue;
            }

            // If the value has changed, we better change it
            if ($cookie->value() !== $c->value()) {
                unset($this->_data[$i]);
                continue;
            }

            // The cookie exists, so no need to continue
            return false;
        }

        $this->_data[] = $cookie;

        return true;
    }
327860
private function encodeCookie(Cookie $cookie): Cookie
    {
        if ($this->config->cookieProtectionMethod() == HttpConfig::COOKIE_ENCRYPT) {
            $encrypter = $this->encryption->getEncrypter();

            return $cookie->withValue($encrypter->encrypt($cookie->getValue()));
        }

        //VALUE.HMAC
        return $cookie->withValue($cookie->getValue() . $this->hmacSign($cookie->getValue()));
    }
186699
public function setSiteCookie($cookie, $value, $expire, $path="/") {
    // bool setcookie ( string $name [, string $value [, int $expire = 0
    // [, string $path [, string $domain [, bool $secure = false
    // [, bool $httponly = false ]]]]]] )

    $ref = $this->siteDomain;

    if(!setcookie($cookie, $value, $expire, $path, $ref)) {
      return false;
    }
    return true;
  }
425044
protected function serveCookies($cookies)
    {
        foreach ($cookies as $cookie) {
            if ($cookie->hasChanged()) {
                $expiration = $cookie->getExpiration();
                if (isset($expiration)) {
                    $expiration = $expiration->getTimestamp();
                } else {
                    $expiration = 0;
                }
                setcookie(
                    $cookie->getName(),
                    $cookie->get(),
                    $expiration,
                    $cookie->getPath(),
                    $cookie->getDomain(),
                    $cookie->isSecure(),
                    $cookie->isHttpOnly()
                );
            }
        }
    }
850154
public function cookie($cookie = null) {
        if ($cookie === null) {
            $this->cookies = [];
        } else {
            $this->cookies[] = $cookie;
        }

        return $this;
    }
1077485
public function withCookie(Cookie $cookie)
    {
        $clone = clone $this;
        $clone->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
        return $clone;
    }