I am working on a website that depends on a complex cookie being set. In an effort to fix problems before they become big problems, I want to monitor that the cookie is getting set correctly with a cron job. I can setup the cron job just fine, but I can't figure out how to get the value of the cookie.
By visiting the main site the cookie is set automatically, and I've also made a special script on that server that only gets me that cookie value and spits it out. I am trying to use cURL to call the main page, and then right after that, call the get-cookie.php page which should then have cookie data to display.
Here is how I am trying to do it now:
<?php
$c = curl_init();
// making the initial call to the real website
curl_setopt($c, CURLOPT_URL, 'http://domain.com');
curl_setopt($c, CURLOPT_HEADER, false);
curl_exec($c);
curl_close($c);
$c = curl_init();
// now making a call to the script that spits out the cookie
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, 'http://domain.com/get-cookie.php');
curl_setopt($c, CURLOPT_HEADER, false);
$output = curl_exec($c);
curl_close($c);
echo 'output: ' . $output . "\n\n";
?>
I've tried a few different things here, but so far no luck. Anyone have any ideas on how I can make this work? Thanks so much!