Http\Response->cookie
设置HTTP
响应的cookie
信息。此方法参数与PHP
的setcookie
完全一致。
function Http\Response->cookie(string $key, string $value = '', int $expire = 0 , string $path = '/', string $domain = '', bool $secure = false , bool $httponly = false, string $samesite = '');
cookie设置必须在end方法之前
$samesite
参数从v4.4.6
版本开始支持
注意事项
- 底层自动会对
$value
进行urlencode
编码,可使用rawCookie
关闭对$value
的编码处理 - 底层允许设置多个相同
$key
的COOKIE