curlopt_cookie有關問題

來源:互聯網
上載者:User
curlopt_cookie問題
我使用curlopt_cookie 發現前一個COOKIE會覆蓋後一個COOKIE。。而且寫法上也出現了問題,列印的結果不是想要的,不正確的


$PostData = array(
'zipCode' => '12345',
'langId' => '-1',
'storeId' => '10001',
'URL' => '/Brother-TN-580-Toner-Cartridge-High-Yield/product_612784',
'errorUrl' => 'zipcode'
);
$ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)';
$url = 'http://www.staples.com/Brother-TN-580-Toner-Cartridge-High-Yield/product_612784';
$host = $_SERVER['DOCUMENT_ROOT'];

if ( $curl = curl_init() )
{
curl_setopt($curl, CURLOPT_URL, 'http://www.chenzhi.com/2.php');
curl_setopt($curl, CURLOPT_COOKIE, 'CoreID6=30201255514912193294815;Path=/;Domain=www.chenzhi.com;expires=Mon, 13-Oct-24 13:08:16 GMT');
curl_setopt($curl, CURLOPT_COOKIE, 'TestSess3=x;Path=/;Domain=www.chenzhi.com;expires=End Of Session');
curl_setopt($curl, CURLOPT_COOKIE, '90028341_login=1255528626018461671490028341;Path=/;Domain=www.chenzhi.com;expires=End Of Session');
curl_setopt($curl, CURLOPT_COOKIE, '90028341_reset=1255528626;Path=/;Domain=www.chenzhi.com;expires=End Of Session');

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);

curl_exec($curl);
curl_close($curl);
} else {
die('1 fails:' . curl_error($curl));
}

unset($curl);



列印的結果
Array
(
[90028341_reset] => 1255528626
[Path] => /
[Domain] => www.chenzhi.com
[expires] => End Of Session
)




而正常的setcookie顯示的結果確是
setcookie("TestCookie1", '1', time()+3600, "/", 'www.chenzhi.com');
setcookie("TestCookie2", '2', time()+3600, "/", 'www.chenzhi.com');
setcookie("TestCookie3", '3', time()+3600, "/", 'www.chenzhi.com');
setcookie("TestCookie4", '4', time()+3600, "/", 'www.chenzhi.com');
echo '
';
print_r($_COOKIE);
echo '
';


Array
(
[TestCookie1] => 1
[TestCookie2] => 2
[TestCookie3] => 3
[TestCookie4] => 4
)




請問大神們如何把多個COOKIE的值用CURLOPT_COOKIE寫出來??求解 Cookie Curl
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.