Set the cookie.

@throws \Exceptions Cookies already set

@return bool
187718
public function store()
    {
        if ($this->name && $this->setCookie == true) {
            throw new InvalidCookieException('Cookies can only set once.');
        }

        $bool = setcookie(
            $this->name,
            $this->value,
            $this->expire,
            $this->path,
            $this->domain,
            $this->secure,
            $this->httpOnly
        );

        if ($bool == true) {
            $this->setCookie = true;
        }

        return $bool;
    }
729856
protected function syncCookies()
    {
        foreach ($this->cookies as $name => $id) {
            if (null === $id) {
                setcookie($name, '', time() - 3600);
            } else {
                setcookie(
                    $name,
                    $id,
                    $this->ttl ? (time() + $this->ttl) : 0,
                    $this->path,
                    $this->domain,
                    $this->secure,
                    $this->httponly
                );
            }
        }
    }
88724
def set_cookie!
      cookies[:user_session] = {
        :value => self.temporary_token,
        :secure => controller.request.ssl?,
        :httponly => true,
        :expires => self.expires_at
      }
      Authie.config.events.dispatch(:session_cookie_updated, self)
      true
    end
1154521
public function restoreLoginFromCookie()
    {
        if (! $this->cookieIsSet()) {
            return false;
        }

        $fields = $this->config('fields');
        $cookieKey = $this->config('cookieKey');
        $loginData = [];

        foreach ($fields as $field) {
            if ($this->Cookie->check("$cookieKey.$field")) {
                $loginData[$field] = $this->Cookie->read("$cookieKey.$field");
            }
        }

        // $controller->request->data might need to be copied over to $this->request->data, depending on how Auth is looking for it
        $controller = $this->_registry->getController();
        $tempRequest = $controller->request->data;
        $controller->request->data = $loginData;
        $user = $controller->Auth->identify();
        $controller->request->data = $tempRequest;

        if ($user) {
            $controller->Auth->setUser($user);
            return true;
        }

        return false;
    }
586615
private function setCookiesFromHeaders()
    {
        $this->cookies = [];

        $headers = $this->getHeaderAsArray('Cookie');

        foreach ($headers as $line) {
            foreach (explode(';', $line) as $pair) {
                $cookie = BasicCookie::fromHeader($pair);
                $this->cookies[$cookie->getName()] = $cookie;
            }
        }
    }
1143494
private function setCookiesFromHeaders()
    {
        $this->cookies = [];

        $headers = $this->getHeaderArray("set-cookie");

        foreach ($headers as $line) {
            $cookie = ResponseCookie::fromHeader($line);
            $this->cookies[$cookie->getName()] = $cookie;
        }
    }
1089638
public function set(\BearFramework\App\Response\Cookie $cookie): self
    {
        $this->data[$cookie->name] = $cookie;
        return $this;
    }
980901
def set_cookie(self, cookie):
        """"""
        c = self._cookies
        self._cookies_lock.acquire()
        try:
            if cookie.domain not in c: c[cookie.domain] = {}
            c2 = c[cookie.domain]
            if cookie.path not in c2: c2[cookie.path] = {}
            c3 = c2[cookie.path]
            c3[cookie.name] = cookie
        finally:
            self._cookies_lock.release()
1012901
private function setCookie()
    {
        setcookie(
            $this->cookieName,
            $this->sessionId,
            ($this->expireOnClose) ? 0 : $this->now + $this->secondsUntilExpiration,
            '/',
            null,
            $this->secureCookie,
            true
        );
    }
972109
public function send()
	{
		$result = true;

		// process the cookies in this jar
		foreach ($this->jar as $cookie)
		{
			if ( ! $cookie->send())
			{
				$result = false;
			}
		}

		// and the cookies in this jar's children
		foreach ($this->children as $cookie)
		{
			if ( ! $cookie->send())
			{
				$result = false;
			}
		}

		return $result;
	}
729455
protected function getCookies() {
    $current_request = $this->requestStack->getCurrentRequest();
    if (isset($current_request->cookies)) {
      return $current_request->cookies->all();
    }
    return $_COOKIE;
  }
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;
    }
728686
public function setCookie(Cookie $cookie) : self
    {
        $this->cookies[$cookie->getName()] = $cookie;

        return $this;
    }
165968
public function setCookie(CookieJar $cookie)
    {
        return $this->getCache()->save($this->getCacheKey(), $cookie, Config::get('cache.expire', 100));
    }
1237052
public function sendCookie()
    {
        $time = time();
        // Anonymous function for unit test
        $setCookie = function () {
        };
        foreach ($this->cookies as $name => $o) {
            $o += $this->cookieOption;
            $fn = $this->unitTest ? $setCookie : ($o['raw'] ? 'setrawcookie' : 'setcookie');
            $fn($name, $o['value'], $time + $o['expires'], $o['path'], $o['domain'], $o['secure'], $o['httpOnly']);
        }
        return $this;
    }
879378
protected function setCookie(): void
	{
		if($this->options['cookie_options']['secure'] && !$this->request->isSecure())
		{
			throw new RuntimeException('Attempted to set a secure cookie over a non-secure connection.');
		}

		$this->response->getCookies()->addSigned($this->options['name'], $this->sessionId, $this->options['cookie_ttl'], $this->options['cookie_options']);
	}
390669
public function start()
    {
        // Protection against invalid session cookie names throwing exception: http://php.net/manual/en/function.session-id.php#116836
        if (isset($_COOKIE[session_name()]) && !preg_match('/^[-,a-zA-Z0-9]{1,128}$/', $_COOKIE[session_name()])) {
            unset($_COOKIE[session_name()]);
        }

        if (!session_start()) {
            throw new \RuntimeException('Failed to start session.', 500);
        }

        $this->started = true;

        return $this;
    }