阅读(2728) (0)

Laravel 8 Cookies

2021-07-08 09:45:49 更新

在发送请求前你可以使用 withCookiewithCookies 方法设置 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('/');
    }
}