Edit report at https://bugs.php.net/bug.php?id=62942&edit=1

 ID:                 62942
 Updated by:         larue...@php.net
 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:

it's not a bug, cookie_*** options are exclusive


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to