Edit report at https://bugs.php.net/bug.php?id=62942&edit=1
ID: 62942
User updated by: ben at blinkmobile dot com dot au
Reported by: ben at blinkmobile dot com dot au
Summary: Setting CURLOPT_COOKIE with curl_setopt_array
problem
Status: Open
Type: Bug
Package: cURL related
PHP Version: 5.3.16
Block user comment: N
Private report: N
New Comment:
Thanks Laruence. Is this documented anywhere? I couldn't find it.
Also, it appears that curl_setopt isn't enforcing the exclusivity. The
following
2 tests both attach $cookies fine on PHP 5.3.15:
$cookies = 'a=b';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://...');
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, '');
curl_setopt($ch, CURLOPT_COOKIEJAR, '');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_exec($ch);
curl_close($ch);
$cookies = 'a=b';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://...');
curl_setopt($ch, CURLOPT_COOKIEFILE, '');
curl_setopt($ch, CURLOPT_COOKIEJAR, '');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_exec($ch);
curl_close($ch);
I notice that the curl library between my tests was upgraded from 7.19.7 to
7.24.0. Perhaps it was this and not https://bugs.php.net/bug.php?id=61948 ?
If there is documentation for this exclusivity it would be good to include a
link
here and on http://au2.php.net/manual/en/function.curl-setopt.php and
http://au2.php.net/manual/en/function.curl-setopt-array.php because people's
existing (however incorrect) code might break when they upgrade PHP or CURL.
Previous Comments:
------------------------------------------------------------------------
[2012-08-27 02:55:28] [email protected]
it's not a bug, cookie_*** options are exclusive
------------------------------------------------------------------------
[2012-08-27 01:53:39] ben at blinkmobile dot com dot au
Description:
------------
Setting CURLOPT_COOKIE with curl_setopt_array must be done before setting
CURLOPT_COOKIEFILE or CURLOPT_COOKIEJAR.
I'm not sure if this is a bug, however I can't find documentation explaining
that
when using curl_setopt_array you need to set options in a particular order.
It was working in PHP 5.3.13, however fails in 5.3.14 + 5.3.15
A change that could have caused this is https://bugs.php.net/bug.php?id=61948
Test script:
---------------
$cookies = 'a=b';
// the following correctly attaches $cookies in PHP 5.3.13 but not PHP 5.3.14+
$options = array(
CURLOPT_URL => 'http://...',
CURLOPT_COOKIEFILE => '',
CURLOPT_COOKIEJAR => '',
CURLOPT_HEADER => true,
CURLOPT_COOKIE => $cookies,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
// the following attaches $cookies correctly for all versions I have tested
$options = array(
CURLOPT_URL => 'http://...',
CURLOPT_COOKIE => $cookies,
CURLOPT_COOKIEFILE => '',
CURLOPT_COOKIEJAR => '',
CURLOPT_HEADER => true,
);
$ch = curl_init();
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62942&edit=1