src/Response.php
public function cookie($key = null, $value = null)
    {
        if (null === $key)
        {
            return $this->_cookies;
        }
        elseif ( ! is_array($key) && ! $value)
        {
            return Arr::get($this->_cookies, $key);
        }

        if (is_array($key))
        {
            foreach ($key as $k => $v)
            {
                $this->cookie($k, $v);
            }
        }
        else
        {
            if ( ! is_array($value))
            {
                $value = [
                    'value'      => $value,
                    'expiration' => Cookie::$expiration,
                ];
            }
            elseif ( ! isset($value['expiration']))
            {
                $value['expiration'] = Cookie::$expiration;
            }

            $this->_cookies[(string) $key] = $value;
        }

        return $this;
    }
public function cookie($key = null, $value = null)
    {
        if (null === $key)
        {
            return $this->_cookies;
        }
        elseif ( ! is_array($key) && ! $value)
        {
            return Arr::get($this->_cookies, $key);
        }

        if (is_array($key))
        {
            foreach ($key as $k => $v)
            {
                $this->cookie($k, $v);
            }
        }
        else
        {
            if ( ! is_array($value))
            {
                $value = [
                    'value'      => $value,
                    'expiration' => Cookie::$expiration,
                ];
            }
            elseif ( ! isset($value['expiration']))
            {
                $value['expiration'] = Cookie::$expiration;
            }

            $this->_cookies[(string) $key] = $value;
        }

        return $this;
    }
设置或者读取cookie

// 读取cookie
$cookies = $response->cookie();

// 写cookie
$response->cookie('session', [
'value' => $value,
'expiration' => 12352234
]);

@param  mixed  $key   cookie名
@param  string $value cookie值
@return $this|mixed