你也可以使用curl來存儲cookiedata(和會話內容)。所以基本上,你先訪問網站,然後到達郊區。示例代碼:
$mainurl = "http://www.basket.ee/"
$ripurl = "http://www.basket.ee/index.php?mid=469&round=1&sid=2013&chid=001&tase=1"
//Put cookie file
$cookieFile = "cookie.txt";
//if file doesn't exist
if(!file_exists($cookieFile)) {
//fopen for writing
$fh = fopen($cookieFile, "w");
//write
fwrite($fh, "");
//close
fclose($fh);
}
//Start session for first login
$ch = curl_init();
//Load curl
curl_setopt($ch, CURLOPT_URL, $mainurl);
//Set cookie file
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
//do not return data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute curl and close
curl_exec($ch);
curl_close ($ch);
//startup curl again
$ch = curl_init($urlxml);
//cookie stuff
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
//store curl result in var
$rawdata=curl_exec($ch);
//Close curl
curl_close ($ch);
echo $rawdata;
使用此操作將會話存儲到cookie var。這使得用戶相信你是一個普通的用戶瀏覽。
有一個名爲'Tamper Data'的firefox插件,用它來查找會話和cookie,然後使用CURL來訪問頁面並保持會話處於活動狀態。 –