尤川豪   ·  5年前
445 貼文  ·  275 留言

GuzzleHttp 發送 request 並模擬保存 cookie 時,cookie 內容是存在哪裡?

this is stateless request:

$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $url);

this is stateful request:

$client = new \GuzzleHttp\Client();
$cookieJar = new \GuzzleHttp\Cookie\CookieJar();
$res = $client->request('GET', $url, ['cookies' => $cookieJar]);

指定 cookiejar 即可啟用 cookie


問:在沒指定檔案路徑的情況下,guzzlehttp 是如何存取的?是存在一個檔案?存在一個變數?

若是用 curl 發送 request,啟用 cookie 要指定檔案吧?

https://stackoverflow.com/questions/16872082/how-can-i-send-cookies-using-php-curl-in-addition-to-curlopt-cookiefile

https://blog.longwin.com.tw/2014/05/php-curl-set-cookie-2014/

使用 guzzle 就不用?

  分享   共 2,201 次點閱
按了喜歡:
共有 0 則留言
還沒有人留言。歡迎分享您的觀點、或是疑問。
您的留言
尤川豪
445 貼文  ·  275 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章