可以在请求时使用CURL请求设置cookie吗?

时间:2010-12-22 06:46:35

标签: php curl

我正在使用curl来获取网页的内容..当我使用浏览器访问网站时,网站设置了Cookie。

我能否以相同的方式使用cURL并向该特定网站发送包含cookie信息的请求...... ????

1 个答案:

答案 0 :(得分:1)

以下是我发现的有关卷曲和饼干的一些选项。

 curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt' ); //use this cookie file
 curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.jar'); //if you close the session the cookies will be saved here
 curl_setopt($ch, CURLOPT_COOKIE,"cookie_test=yes; domain=.google.com; path=/"); //set the cookie for the current session