欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

curlopt_cookie有关问题

程序员文章站 2024-01-26 16:34:28
...
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写出来??求解

网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • curlopt_cookie有关问题
  • 专题推荐

    作者信息
    curlopt_cookie有关问题

    认证0级讲师

    推荐视频教程
  • curlopt_cookie有关问题javascript初级视频教程
  • curlopt_cookie有关问题jquery 基础视频教程
  • 视频教程分类