Cookies
Guzzle可以使用 cookies
请求参数为你维护一个cookie会话,当发送一个请求时, cookies
选项必须设置成 GuzzleHttp\Cookie\CookieJarInterface
的实例。
// Use a specific cookie jar
$jar = new \GuzzleHttp\Cookie\CookieJar;
$r = $client->request('GET', 'http://httpbin.org/cookies', [
'cookies' => $jar
]);
You can set cookies
to true
in a client constructor if you would like to use a shared cookie jar for all requests.
// Use a shared client cookie jar
$client = new \GuzzleHttp\Client(['cookies' => true]);
$r = $client->request('GET', 'http://httpbin.org/cookies');