简体   繁体   中英

Problem with cookies in httpClient in Zend Framework

I create the httpClient in Zend framework to make page requests. I am trying to add a cookie but it does not seem to work according to the data which I get. Can you please tell me what am I doing wrong?

$httpClient = new HttpClient();
$httpClient->setConfig 
(array(
    'timeout'     => 30, 
    'useragent'   => "Opera/9.80 (Windows NT 5.1; U; ru)Version/10.62",
    'adapter'     => 'Zend_Http_Client_Adapter_Curl', 
    'curloptions' => array 
    (
        CURLOPT_TIMEOUT          => 30,
        CURLOPT_FRESH_CONNECT    => true,
    ),
));


$httpClient->setCookieJar();

$cookie = Zend_Http_Cookie::fromString('abc=1000; ' +
                                       'domain=.abc.ru; ' +
                                       'path=/; ' +
                                       'expires=Wednesday, 28-Feb-12 20:41:22 UTC');
$httpClient->setCookie($cookie);

You cannot join strings with plus sign in PHP:

'abc=1000; ' +
'domain=.abc.ru; ' +
'path=/; ' +
'expires=Wednesday, 28-Feb-12 20:41:22 UTC'

Plus sign is arithmetic operator and this statement simply results in '0'. Use '.' operator .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM