我有這個腳本,它有一個登錄用戶,所以用戶只能使用他的用戶名/密碼登錄!使用cURL功能後,會話將不會工作
一切正常,就是在頁面我使用curl功能的唯一問題,那麼它將不會再識別用戶會話,一旦我得到了該網頁,並移動到另一個..
這裏是捲曲文件代碼:
<?php session_start();
require_once('db.php');
include('functions.php');
checkLogin('1');
$query = 'SELECT * FROM users WHERE ID="'.$_SESSION['user_id'].'"';
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$id_user=$row['user_id'];
$phone=$row['phone'];
$name=$row['first_name'];
}
?>
<?php
if ($points == 250) {
$b = time();
$date1 =date("Y-m-d;h:i:s" , mktime(date("h")+6, date("i"), date("s"), date("m") , date("d"), date("Y")));
$str_time = "";
$str_msg = "";
$str_from = "";
$str_zip = "";
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg);
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
}
else if ($points == 500) {
$b = time();
$date1 =date("Y-m-d;h:i:s" , mktime(date("h")+6, date("i"), date("s"), date("m") , date("d"), date("Y")));
$str_time = "";
$str_msg = "";
$str_from = "";
$str_zip = "";
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://testext.i-movo.com/api/receivesms.aspx?".$str_from.$str_zip.$phone.$str_time.$date1.$str_msg);
curl_setopt($ch, CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
}
else {
echo "We are sorry, you don't possess enough points in order to take the coupon";
}
echo '</div>';
?>
curl不會干擾現有會話(除非您通過curl請求PHP代碼,然後eval()it)。確認你在其他頁面上調用了'session_start()'。 –
請不要使用'mysql_ *'函數來編寫新代碼。他們不再維護,社區已經開始[棄用程序](http://goo.gl/KJveJ)。請參閱* [紅盒子](http://goo.gl/GPmFd)*?相反,您應該瞭解[準備好的語句](http://goo.gl/vn8zQ)並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli的)。如果你不能決定哪些,[這篇文章](http://goo.gl/3gqF9)會幫助你。如果你選擇PDO,[這裏是很好的教程](http://goo.gl/vFWnC)。 –
我已經召集會議開始到處..我找不到原因.. –