Forum Moderators: coopster
<?
$string = "cookie=test";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://example.com");
curl_setopt($ch, CURLOPT_COOKIE, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($ch);
curl_close($ch);
?>
is that not what this code does?
I might be pointing out something very silly here... but since you are using
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec() is returning the results as a string and not directly to the page. You might want to try:
<?
$string = 'cookie=atestcookie';$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com");
curl_setopt($ch, CURLOPT_COOKIE, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$text = curl_exec($ch);
curl_close($ch);
die($text);
?>
Otherwise, I do not see anything obviously wrong with your code for setting the cookie. Hope that is of some help!
- Travis