200806180059PHP cURL 中 CURLOPT_COOKIEFILE 和 CURLOPT_COOKIEJAR 的差別
PHP cURL 的 option 中有兩項名字很接近 - CURLOPT_COOKIEFILE 和 CURLOPT_COOKIEJAR , PHP: curl_setopt - Manual 裡對 CURLOPT_COOKIEFILE 和 CURLOPT_COOKIEJAR 的介紹分別是︰
CURLOPT_COOKIEFILE
The name of the file containing the cookie data. The cookie file can be in Netscape format, or just plain HTTP-style headers dumped into a file.
CURLOPT_COOKIEJAR
The name of a file to save all internal cookies to when the connection closes.
看完介紹還是霧煞煞,不知道兩者到底有什麼差別。
我測試的結果︰
CURLOPT_COOKIEJAR 是 CURL 收到的 HTTP Response 中的 Set-Cookie 要存放在哪。
CURLOPT_COOKIEFILE 是 CURL 要發出的 HTTP Request 的 Cookie 存放在哪。
回應