//如果访问地址是自身的话直接获取$_COOKIE组装一下然后发送
<?php
$url = "http://www.xxx.com/a.php";
$ch = curl_init();
$cookie = "";
foreach($_COOKIE as $k=>$v) {
$cookie .= $k."=".$v.";";
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$html = curl_exec($ch);
var_dump($html);
curl_close($ch);
//如果访问的是其他站点的地址
//首先获取远程站点cookie
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefile");
curl_setopt($curl, CURLOPT_URL, $url1);
$html = curl_exec($curl);
//然后带着cookie请求远程站点
curl_setopt($curl, CURLOPT_COOKIEFILE, "cookiefile");
curl_setopt($curl, CURLOPT_URL, $url2);
$html = curl_exec($curl);
var_dump($html);
curl_close ($curl);
?>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。