如何在发出请求后从Guzzle请求/客户端检索Cookie?
$client = new Client([
'base_uri' => 'www.google.com',
]);
$response = $client->request('GET', '/');
答案 0 :(得分:13)
请阅读the docs。您必须使用CookieJar
类来处理cookie。
$client = new \GuzzleHttp\Client(['cookies' => true]);
$r = $client->request('GET', 'http://httpbin.org/cookies');
$cookieJar = $client->getConfig('cookies');
$cookieJar->toArray();