0

Here is my code:

$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: ChosenSite=www"));
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: SportsDirect_AnonymousUserCurrency=GBP"));
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: language=en-GB"));
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($curl, CURLOPT_VERBOSE, true);
 $str = curl_exec($curl);  
 curl_close($curl); 

I am trying to set these cookies as i am trying to parse HTML dom elements but it seems i am not able to set them correctly.

Can you please tell me where is my mistake, I am setting cookies correctly ?

Thanks in advance!

Venelin
  • 2,905
  • 7
  • 53
  • 117
  • 1
    Does `setopt` work like that? I think you're overriding the cookie. I think it should be something like: `curl_setopt($curl, CURLOPT_HTTPHEADER, array("Cookie: ChosenSite=www;SportsDirect_AnonymousUserCurrency=GBP;language=en-GB"));`. I'm not eniterly sure on the syntax. – Halcyon Mar 09 '16 at 13:24
  • Check similar question [here](http://stackoverflow.com/questions/16872082/how-can-i-send-cookies-using-php-curl-in-addition-to-curlopt-cookiefile) and [here](http://stackoverflow.com/questions/10570341/is-it-possible-to-set-the-cookie-content-with-curl) – Minesh Patel Mar 09 '16 at 13:33

0 Answers0