Warum speichert PHP Curl Cookies nicht in meinem Cookie?
Ich versuche, ein Cookie im Curl-Cookiejar zu speichern. Ich habe meinen Code vereinfacht, aber es funktioniert nicht.
<?php
$cookie_file = './cookies.txt';
if (! file_exists($cookie_file) || ! is_writable($cookie_file)){
echo 'Cookie file missing or not writable.';
exit;
}//cookie_file is writable, so this is not the issue
$ch = curl_init (html_entity_decode("http://localhost/kiala_test/setcookie.php"));
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec ($ch);
echo $output;
?>
setcookie.php
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
?>
Header erhalten
HTTP / 1.1 200 OK Datum: Do, 10. Oktober 2013, 12:10:37 Uhr GMT-Server: Apache / 2.4.4 (Win64) PHP / 5.4.12 X-Powered-By: PHP / 5.4.12 Set-Cookie: TestCookie = irgendwas + von + irgendwo Content-Länge: 0 Content-Typ: text / html
Der Testcookie steht also in der Kopfzeile, aber mein Cookie bleibt leer. Was mache ich falsch? Was kann ich versuchen, damit dieses Beispiel funktioniert? Danke dir!