Goose Posted January 19, 2011 Share Posted January 19, 2011 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! Link to comment https://forums.phpfreaks.com/topic/224998-get-a-cookie-value-with-curl/ Share on other sites More sharing options...
Goose Posted January 21, 2011 Author Share Posted January 21, 2011 bump Link to comment https://forums.phpfreaks.com/topic/224998-get-a-cookie-value-with-curl/#findComment-1163133 Share on other sites More sharing options...
BlueSkyIS Posted January 21, 2011 Share Posted January 21, 2011 i don't see any cookie handling in the code. http://coderscult.com/php/php-curl/2008/05/20/php-curl-cookies-example/ Link to comment https://forums.phpfreaks.com/topic/224998-get-a-cookie-value-with-curl/#findComment-1163139 Share on other sites More sharing options...
Goose Posted January 21, 2011 Author Share Posted January 21, 2011 That's exactly what I was looking for. Thanks!!! Link to comment https://forums.phpfreaks.com/topic/224998-get-a-cookie-value-with-curl/#findComment-1163154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.