开发者

Curl how to use cookies

Hey i am trying to use cookies in curl, but I can not get it to work so basically what I need is to when loading the url set cookie with ab = 1 ab2 = 3 and ab3 = 10, I tried loading cookies but that does开发者_C百科nt work then i tried this code

curl_setopt($curl,array('Cookie: ab=1,ab2=3,ab3=10')); 

but I am getting errors.


You're using curl_setopt wrong, and the format of your cookie isn't quite right.

curl_setopt($curl, CURLOPT_COOKIE, 'ab=1; ab2=3; ab3=10');


You're calling curl_set_optPHP Manual wrong. Your version is for setting a single option. If you want to pass an array of options, then you have to use curl_setopt_arrayPHP Manual.

Try:

curl_setopt($curl, CURLOPT_COOKIE, "ab=1, ab2=3, ab3=10")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜