src/Leevel/Http/Psr2Leevel.php
protected function createCookie(string $cookie): array
    {
        foreach (explode(';', $cookie) as $part) {
            $part = trim($part);

            $data = explode('=', $part, 2);
            $name = $data[0];
            $value = isset($data[1]) ? trim($data[1], " \n\r\t\0\x0B\"") : null;

            if (!isset($cookieName)) {
                $cookieName = $name;
                $cookieValue = $value;

                continue;
            }

            if ('expires' === strtolower($name) && null !== $value) {
                $cookieExpire = new DateTime($value);

                continue;
            }

            if ('path' === strtolower($name) && null !== $value) {
                $cookiePath = $value;

                continue;
            }

            if ('domain' === strtolower($name) && null !== $value) {
                $cookieDomain = $value;

                continue;
            }

            if ('secure' === strtolower($name)) {
                $cookieSecure = true;

                continue;
            }

            if ('httponly' === strtolower($name)) {
                $cookieHttpOnly = true;

                continue;
            }
        }

        if (!isset($cookieName)) {
            throw new InvalidArgumentException('The value of the Set-Cookie header is malformed.');
        }

        return [
            $cookieName,
            $cookieValue,
            [
                'expire'   => $cookieExpire ?? 0,
                'path'     => $cookiePath ?? '/',
                'domain'   => $cookieDomain ?? null,
                'secure'   => isset($cookieSecure),
                'httponly' => isset($cookieHttpOnly),
            ],
        ];
    }
protected function createCookie(string $cookie): array
    {
        foreach (explode(';', $cookie) as $part) {
            $part = trim($part);

            $data = explode('=', $part, 2);
            $name = $data[0];
            $value = isset($data[1]) ? trim($data[1], " \n\r\t\0\x0B\"") : null;

            if (!isset($cookieName)) {
                $cookieName = $name;
                $cookieValue = $value;

                continue;
            }

            if ('expires' === strtolower($name) && null !== $value) {
                $cookieExpire = new DateTime($value);

                continue;
            }

            if ('path' === strtolower($name) && null !== $value) {
                $cookiePath = $value;

                continue;
            }

            if ('domain' === strtolower($name) && null !== $value) {
                $cookieDomain = $value;

                continue;
            }

            if ('secure' === strtolower($name)) {
                $cookieSecure = true;

                continue;
            }

            if ('httponly' === strtolower($name)) {
                $cookieHttpOnly = true;

                continue;
            }
        }

        if (!isset($cookieName)) {
            throw new InvalidArgumentException('The value of the Set-Cookie header is malformed.');
        }

        return [
            $cookieName,
            $cookieValue,
            [
                'expire'   => $cookieExpire ?? 0,
                'path'     => $cookiePath ?? '/',
                'domain'   => $cookieDomain ?? null,
                'secure'   => isset($cookieSecure),
                'httponly' => isset($cookieHttpOnly),
            ],
        ];
    }
创建 COOKIE 结构.

Some snippets have been taken from the Guzzle app: https://github.com/guzzle/guzzle/blob/5.3/src/Cookie/SetCookie.php#L34

@param string $cookie

@return array