Hello all and thanks for any tip/advice.
I have the following code:
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$myurl = $_SERVER['DOCUMENT_ROOT'].'/somepage.php?var1=aaa&var2=bbb';
$fetched_data = get_data($myurl);
The target page ($myurl) checks for the existence of a cookie with this:
if (isset($_COOKIE['mycookie']))
{
// show [dataset 1]
}
else
{
// show [dataset 2]
}
The problem is that my $fetched_data always return the [dataset 2] data, even if cookie exists.
Is there a way to fix this? Should i modify anything in my curl()?
Take note that i know all the data that are stored in the $_COOKIE