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 ?

4
  • just create target demo page in your local environment and try to send cookies to that page Commented Aug 9, 2019 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? Commented Aug 9, 2019 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 Commented Aug 9, 2019 at 14:00
  • 1
    Di you try curl_setopt($ch, CURLOPT_COOKIE, "test=cookie"); ? Commented Aug 9, 2019 at 14:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.