0

I'm trying to make a CURL request which passes a cookie to another website. I am not to sure if I am even doing this correctly my code is below. The code below I have tried but I have no clue whether the cookie is being passed it would appear not as the PHP echo shows no trace of the Cookie.

Source test page - This appears to not be sending the cookie properly.

$cSession = curl_init(); 
curl_setopt($cSession,CURLOPT_URL,"https://www.test.com/testpage.php");
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: test=cookie"));
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result=curl_exec($cSession);
curl_close($cSession);
echo $result;    
fclose($temp);

Target Curl Test Page

<?php
echo "You've Curled me ";
echo $_COOKIE['test'];
?>

Also is there a better way I can test if the cookie is sent other than JavaScript or PHP ?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • just create target demo page in your local environment and try to send cookies to that page – Kaushal shah Aug 09 '19 at 13:50
  • @kaushal shah I did that already thats what the second page is however the cookies arent being passed. Thats my question what is incorrect in the code? – John Bailey Aug 09 '19 at 13:58
  • @ Raymond Nijland different issue sir mine is with the cookies not being sent in part 1 of the question. I've seen the post mentioned. thanks – John Bailey Aug 09 '19 at 14:00
  • 1
    Di you try curl_setopt($ch, CURLOPT_COOKIE, "test=cookie"); ? – mjspier Aug 09 '19 at 14:10

0 Answers0