Есть такой скрипт:
| Код | <? $cookie=file('cookie.txt'); for($i=3;$i<count($cookie);$i++) { $cs=explode("\t",$cookie[$i]); $arr_cookie[]=trim($cs[5])."=" .trim($cs[6])."; "; }
$url = "http://localhost/login/index.php"; $c_file = realpath(dirname(__FILE__)).'/cookie.txt'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt ( $ch , CURLOPT_VERBOSE , 1 ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); //curl_setopt($ch, CURLOPT_COOKIEJAR, $c_file); //curl_setopt($ch, CURLOPT_COOKIEFILE, $c_file); curl_setopt($ch, CURLOPT_POSTFIELDS,"username=amiga11&password=11111&testcookies=1"); curl_setopt($ch, CURLOPT_COOKIEJAR, $c_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $c_file); $page = curl_exec ($ch); //echo $page;
if (@is_array($arr_cookie)){ foreach($arr_cookie as $value){ $COKKIES .= $value; } curl_setopt ( $ch , CURLOPT_COOKIE , $COKKIES." expires=".date('D, d-M-m H:i:s \G\M\T') ); } curl_setopt($ch, CURLOPT_URL,'http://localhost/user.php?id=167'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt ( $ch , CURLOPT_REFERER , 'http://localhost/user.php' ); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $page = curl_exec ($ch); echo $page;
?>
|
Отправляю данные пост методом, получаю cookies открываю страницу http://localhost/user.php все нормально(пишет что я залогинен) а вот при открытии другой страницы http://localhost/user.php?id=167 пишет ошибку..
в чем может быть проблема? как правельно посылать куки? |