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_opt
PHP 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_array
PHP Manual.
Try:
curl_setopt($curl, CURLOPT_COOKIE, "ab=1, ab2=3, ab3=10")
精彩评论