就不长篇大论了,直接贴示例代码吧
$client = new \GuzzleHttp\Client(); $jar = new \GuzzleHttp\Cookie\CookieJar(); $domain = 'www.baidu.com'; $cookies = [ 'sessionid' => '123456', ]; $cookieJar = $jar->fromArray($cookies, $domain); return $client->request('GET', 'www.baidu.com', ['cookies' => $cookieJar]);