cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Bug or strange behavior with CURLOPT_COOKIE: cookie value disappears

From: Mikkel T. Kromann <mikkel.t.kromann_at_get2net.dk>
Date: Mon, 24 Mar 2008 13:49:54 +0100

Hi.

I have a strange problem (possibly a bug, or possibly my lack of
understanding of curl or cookies or both).

When I try to use CURLOPT_COOKIE I'm not able to set the value of the
cookie to anything but empty (print_r($_COOKIE) shows only the cookie
name as key, while the value is empty).

This problem is only with my local SuSE linux 10.2 installation, but not
on my web hotel. Perhaps some of you could kindly point me to some
configuration option that I've missed, or to an appropriate updated
version of php/curl?

I've created two small scripts (supplied below) for reproduction of the
behavior (link to output supplied below). A target script which returns
the content of the $_COOKIE variable and a wrapper script which supplies
the target script with a cookie prints the output of the target script.

I'd be happy to supply further information (version information supplied
below) - just tell me what you need (and perhaps how - I'm not that
fluid in http headers ;) ...

Another question: Could anyone perhaps supply an example of using
CURLOPT_COOKIE with multiple cookies which contain expiration dates and
paths? (btw: that would be nice to have in the PHP documentation ...)

thanks

Mikkel

>uname -a
Linux scrat 2.6.18.8-0.3-default #1 SMP Tue Apr 17 08:42:35 UTC 2007
i686 i686 i386 GNU/Linux

> curl _V
curl 7.15.5 (i686-suse-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8d
zlib/1.2.3 libidn/0.6.8
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: IDN IPv6 Largefile NTLM SSL libz

# This is the contents of target.php
<?php print_r($_COOKIE); ?>

# This is the contents of wrapper.php
<?php
print "This is the $_COOKIE array output by target.php \r\n";
$ch = curl_init("http://10.0.0.4/cURLtest/target.php");
curl_setopt($ch, CURLOPT_COOKIE, "id=242; ");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$test = curl_exec($ch);
curl_close($ch);
print $test;
phpinfo();
?>

I've saved the output of wrapper.php on a public website for your
inspection (details of the problem php installation supplied there):

http://www.teamtracker.dk/wrapper.html

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-03-24