我已经使用手机随附的'通用'浏览器在两款手机型号上测试过我的网站,但不幸的是,每次我尝试登录时,它都会将我退回到我的索引页面。移动浏览器'无法登录我的网站
,这里是我的登录代码
<form name='login' method='POST' action='authentication.php'>
<table border=0 cellpadding=2>
<tr><td>Login:</td><td></td></tr>
<tr><td>E-mail: </td><td><input type=text name='email' id='email' size=20 maxlength="200"></td></tr>
<tr><td>Password: </td><td><input type=password name='password' id='password' size=20 maxlength="100"></td></tr>
<tr><td></td><td><input type=submit value='Login'></td></tr>
</table></form>
和这里的authentication.php(片段)
$currentUserEmail = $_POST["email"];
$currentUserPwd = md5($_POST["password"]);
$stmt = $dbi->prepare("select status from users where email=? and pwd=?");
$stmt->bind_param('ss', $currentUserEmail,$currentUserPwd);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$isUserAvailable = mysqli_stmt_num_rows($stmt);
$stmt->bind_result($getUserStatus);
$stmt->execute() or die (mysqli_error());
$stmt->store_result();
$stmt->fetch();
$stmt->close();
if($isUserAvailable > 0){
if ($getUserStatus == "PENDING") {
$userIsLoggedIn = "NO";
$registeredUser = "NO";
unset($userIsLoggedIn);
setcookie("currentMobileUserName", "", time()-3600);
setcookie("currentMobileUserEmail", "", time()-3600);
setcookie("currentMobileSessionID", "", time()-3600);
setcookie("currentMobileUID", "", time()-3600);
header('Location: '.$config['MOBILE_URL'].'/index.php?error=2&email='.$currentUserEmail);
}elseif (($getUserStatus == "ACTIVE") || ($getUserStatus == "active")){ //means successfully logged in
//set the cookie
setcookie("currentMobileUserName", $currentUserName, $expire);
setcookie("currentMobileUserEmail", $currentUserEmail, $expire);
setcookie("currentMobileSessionID", $getGeneratedMobileUSID, $expire);
setcookie("currentMobileUID", $currentUID, $expire);
$userIsLoggedIn = "YES";
$registeredUser = "YES";
$result = $stmt->execute() or die (mysqli_error($dbi));
if ($caller == "indexLoginForm"){
header('Location: '.$config['MOBILE_URL'].'/home.php');
}else{
header('Location: '.$config['MOBILE_URL'].'/home.php');
}
}
}else{
$userIsLoggedIn = "NO";
$registeredUser = "NO";
unset($userIsLoggedIn);
setcookie("currentMobileUserName", "", time()-3600);
setcookie("currentMobileUserEmail", "", time()-3600);
setcookie("currentMobileSessionID", "", time()-3600);
setcookie("currentMobileUID", "", time()-3600);
header('Location: '.$config['MOBILE_URL'].'/index.php?error=1');
}
我可以使用自己的移动网站的唯一方法是通过使用Opera Mini。只是供参考,两个'通用浏览器'我测试我的网站与支持cookie(至少这是浏览器设置说)。
感谢
您发布的代码并不真正相关,是吗?你在哪里管理会议? – 2010-04-06 10:41:05
我不知道PHP,但不会这行“setcookie(”currentMobileSessionID“,”“,time() - 3600);”将Cookie的到期时间设置为过去一小时?不应该是setcookie(“currentMobileSessionID”,“”,time()+ 3600); ???? – andrewWinn 2010-04-06 11:42:14
对不起,代码是不完整的,并忘记告诉我的手机网站驻留在一个子域。因此我只是添加路径“/”来设置cookie,从 setcookie(“currentMobileUserName”,$ currentUserName,$ expire); 到 setcookie(“currentMobileUserName”,$ currentUserName,$ expire,“/”); 现在它在大多数手机的浏览器上运行良好:D – imin 2010-04-13 04:21:03