¿Por qué php curl no guarda cookie en mi cookiefile?

Estoy tratando de guardar una cookie en el cookiejar curl. He simplificado mi código pero no funciona.

<?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);

?>

encabezado recibido

HTTP / 1.1 200 OK Fecha: jueves, 10 de octubre de 2013 12:10:37 Servidor GMT: Apache / 2.4.4 (Win64) PHP / 5.4.12 X-Powered By: PHP / 5.4.12 Set-Cookie: TestCookie = algo + de + en alguna parte Content-Length: 0 Content-Type: text / html

así que el testcookie está en el encabezado pero mi cocinera permanece vacía. ¿Qué estoy haciendo mal? ¿Qué puedo hacer para que este ejemplo funcione? ¡gracias!

Respuestas a la pregunta(3)

Su respuesta a la pregunta