Rumah > pembangunan bahagian belakang > tutorial php > curlopt_cookie有关问题

curlopt_cookie有关问题

WBOY
Lepaskan: 2016-06-13 12:45:31
asal
1276 orang telah melayarinya

curlopt_cookie问题
我使用curlopt_cookie 发现前一个COOKIE会覆盖后一个COOKIE。。而且写法上也出现了问题,打印的结果不是想要的,不正确的

<br />
$PostData = array(<br />
               'zipCode' => '12345',<br />
               'langId'  => '-1',<br />
               'storeId' => '10001',<br />
               'URL'     => '/Brother-TN-580-Toner-Cartridge-High-Yield/product_612784',<br />
               'errorUrl' => 'zipcode'<br />
              );<br />
$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)'; <br />
$url = 'http://www.staples.com/Brother-TN-580-Toner-Cartridge-High-Yield/product_612784';<br />
$host = $_SERVER['DOCUMENT_ROOT'];<br />
<br />
if ( $curl = curl_init() )<br />
{<br />
   curl_setopt($curl, CURLOPT_URL, 'http://www.chenzhi.com/2.php');<br />
   curl_setopt($curl, CURLOPT_COOKIE, 'CoreID6=30201255514912193294815;Path=/;Domain=www.chenzhi.com;expires=Mon, 13-Oct-24 13:08:16 GMT');<br />
   curl_setopt($curl, CURLOPT_COOKIE, 'TestSess3=x;Path=/;Domain=www.chenzhi.com;expires=End Of Session');<br />
   curl_setopt($curl, CURLOPT_COOKIE, '90028341_login=1255528626018461671490028341;Path=/;Domain=www.chenzhi.com;expires=End Of Session'); <br />
   curl_setopt($curl, CURLOPT_COOKIE, '90028341_reset=1255528626;Path=/;Domain=www.chenzhi.com;expires=End Of Session');<br />
   <br />
   curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);<br />
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);<br />
   <br />
   curl_exec($curl);<br />
   curl_close($curl);<br />
} else {<br />
   die('1 fails:' . curl_error($curl));<br />
}<br />
<br />
unset($curl);
Salin selepas log masuk



打印的结果
Array<br />
(<br />
    [90028341_reset] => 1255528626<br />
    [Path] => /<br />
    [Domain] => www.chenzhi.com<br />
    [expires] => End Of Session<br />
)
Salin selepas log masuk




而正常的setcookie显示的结果确是
<?php<br />
setcookie("TestCookie1", '1', time()+3600, "/", 'www.chenzhi.com');<br />
setcookie("TestCookie2", '2', time()+3600, "/", 'www.chenzhi.com');<br />
setcookie("TestCookie3", '3', time()+3600, "/", 'www.chenzhi.com');<br />
setcookie("TestCookie4", '4', time()+3600, "/", 'www.chenzhi.com');<br />
echo '<pre class="brush:php;toolbar:false">';<br />
print_r($_COOKIE);<br />
echo '
Salin selepas log masuk
';

Array<br />
(<br />
    [TestCookie1] => 1<br />
    [TestCookie2] => 2<br />
    [TestCookie3] => 3<br />
    [TestCookie4] => 4<br />
)
Salin selepas log masuk




请问大神们如何把多个COOKIE的值用CURLOPT_COOKIE写出来??求解

Cookie Curl
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan