Exports the cookies into a JAR string.

@param  object $cookies A `SetCookies` collection.
@return string
965344
public static function toJar($cookies)
    {
        $result = [];
        foreach ($cookies as $name => $cookie) {
            if (!$cookie->expired()) {
                $result[] = static::_line($name, $cookie);
            }
        }
        return $result ? join("\n", $result) . "\n" : '';
    }
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()
                );
            }
        }
    }
58004
public String encode(Cookie cookie) {
        final String name = checkNotNull(cookie, "cookie").name();
        final String value = cookie.value() != null ? cookie.value() : "";

        validateCookie(name, value);

        StringBuilder buf = stringBuilder();

        if (cookie.wrap()) {
            addQuoted(buf, name, value);
        } else {
            add(buf, name, value);
        }

        if (cookie.maxAge() != Long.MIN_VALUE) {
            add(buf, CookieHeaderNames.MAX_AGE, cookie.maxAge());
            Date expires = new Date(cookie.maxAge() * 1000 + System.currentTimeMillis());
            buf.append(CookieHeaderNames.EXPIRES);
            buf.append('=');
            DateFormatter.append(expires, buf);
            buf.append(';');
            buf.append(HttpConstants.SP_CHAR);
        }

        if (cookie.path() != null) {
            add(buf, CookieHeaderNames.PATH, cookie.path());
        }

        if (cookie.domain() != null) {
            add(buf, CookieHeaderNames.DOMAIN, cookie.domain());
        }
        if (cookie.isSecure()) {
            add(buf, CookieHeaderNames.SECURE);
        }
        if (cookie.isHttpOnly()) {
            add(buf, CookieHeaderNames.HTTPONLY);
        }

        return stripTrailingSeparator(buf);
    }
67244
protected function decryptCookie($cookie)
	{
		return is_array($cookie)
						? $this->decryptArray($cookie)
						: $this->encrypter->decrypt($cookie);
	}
280954
public final function cookies(array $cookies = null): array
    {
        return ($cookies == null) ? $this->getCookies() : $this->getCookies($cookies);
    }
1112092
public function getMatchingCookies(Cookie $cookie)
    {
        $match = function ($matchCookie) use ($cookie) {
            return $matchCookie->match($cookie);
        };

        return $this->findMatchingCookies($match);
    }
1102402
private static function getCookies($headers)
    {
        $cookiesRaw = isset($headers['Set-Cookie'])
            ? (array) $headers['Set-Cookie']
            : array();
        $cookies = array();
        foreach ($cookiesRaw as $header) {
            $pairs = \explode(';', $header);
            $pair = \explode('=', $pairs[0]);
            $key = \array_shift($pair);
            $value = \array_shift($pair);
            $cookies[\urldecode($key)] = \urldecode($value);
        }
        return $cookies;
    }
681014
function serializeCookie(cookie) {
  return {
    path: cookie.path,
    name: cookie.key,
    value: cookie.value,
    domain: cookie.domain
  };
}
246271
private static String convertV1Cookie(HttpCookie cookie) {
        StringBuilder buffer = new StringBuilder(40);

        // Append name=value
        buffer.append(cookie.getName());
        buffer.append('=');
        maybeQuote(buffer, cookie.getValue());

        // Always append the version
        buffer.append("; $Version=1");

        // check for optional path
        String value = cookie.getPath();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Path=");
            if (!skipCookiePathQuotes) {
                maybeQuote(buffer, value);
            } else {
                buffer.append(value);
            }
        }

        // check for optional domain
        value = cookie.getDomain();
        if (null != value && 0 != value.length()) {
            buffer.append("; $Domain=");
            maybeQuote(buffer, value);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Created v1 Cookie: [" + buffer.toString() + "]");
        }
        return buffer.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);
    }
1049401
public function setCookies(array $cookies) : Request
    {
        $query = http_build_query($cookies);
        parse_str($query, $this->cookies);

        if ($cookies) {
            $cookie = str_replace('&', '; ', $query);
            $this->setHeader('Cookie', $cookie);
        } else {
            $this->removeHeader('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;
    }
750814
protected static function _line($name, $cookie)
    {
        if (!$cookie->isValid()) {
            throw new RuntimeException("Invalid cookie `'{$name}'`.");
        }
        $domain =  $cookie->domain();

        $parts = [
            $cookie->httponly() ? '#HttpOnly_' . $domain : $domain,
            $domain === '.' ? 'TRUE' : 'FALSE',
            $cookie->path() ?: '/',
            $cookie->secure() ? 'TRUE' : 'FALSE',
            (string) $cookie->expires(),
            $cookie->name(),
            $cookie->value()
        ];
        return join("\t", $parts);
    }
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;
    }
475926
public function setCookie(Cookie $cookie) : Response
    {
        $this->cookies[] = $cookie;
        $this->addHeader('Set-Cookie', (string) $cookie);

        return $this;
    }
138516
private function pack($data, $expire)
    {

        if ($data === '') {
            return '';
        }

        $cookie_data = array();
        $cookie_data['value'] = $data;
        $cookie_data['expire'] = $expire;
        return json_encode($cookie_data);
    }
207042
private function encryptCookie($cookie)
    {
        $data = base64_encode(serialize($cookie));
        $enc = $this->kernel->getContainer()->get('encryption');
        return $enc->input($data)->key($this->kernel->getContainer()->getParameter('app_key'))->encrypt('enc_reversible_pkey')->output();
    }