开发者

Problem with cookies in httpClient in Zend Framework

开发者 https://www.devze.com 2023-01-27 09:05 出处:网络
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 wron

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消