src/Leevel/Http/Cookie.php
public function set(string $name, $value = null, array $option = []): void
    {
        $option = $this->normalizeOptions($option);

        if (is_array($value)) {
            $value = json_encode($value);
        } elseif (!is_string($value) && null !== $value) {
            throw new Exception('Cookie value must be string,array or null.');
        }

        $option['expire'] = (int) ($option['expire']);

        if ($option['expire'] < 0) {
            throw new Exception('Cookie expire date must greater than or equal 0.');
        }

        if ($option['expire'] > 0) {
            $option['expire'] = time() + $option['expire'];
        }

        // 对应 setcookie 的参数
        $this->cookies[$name] = [
            $name,
            $value,
            $option['expire'],
            $option['path'],
            $option['domain'],
            $option['secure'],
            $option['httponly'],
        ];
    }
public function set(string $name, $value = null, array $option = []): void
    {
        $option = $this->normalizeOptions($option);

        if (is_array($value)) {
            $value = json_encode($value);
        } elseif (!is_string($value) && null !== $value) {
            throw new Exception('Cookie value must be string,array or null.');
        }

        $option['expire'] = (int) ($option['expire']);

        if ($option['expire'] < 0) {
            throw new Exception('Cookie expire date must greater than or equal 0.');
        }

        if ($option['expire'] > 0) {
            $option['expire'] = time() + $option['expire'];
        }

        // 对应 setcookie 的参数
        $this->cookies[$name] = [
            $name,
            $value,
            $option['expire'],
            $option['path'],
            $option['domain'],
            $option['secure'],
            $option['httponly'],
        ];
    }
设置 COOKIE.

@param string            $name
@param null|array|string $value
@param array             $option