Laravel 8 Cookies
在发送请求前你可以使用 withCookie 或 withCookies 方法设置 cookie。withCookie 接受 cookie 的名称和值这两个参数,而 withCookies 方法接受一个名称 / 值对数组:
<?php
class ExampleTest extends TestCase
{
public function testCookies()
{
$response = $this->withCookie('color', 'blue')->get('/');
$response = $this->withCookies([
'color' => 'blue',
'name' => 'Taylor',
])->get('/');
}
}