移动浏览器“无法登录到我的网站 [英] mobile browsers' can't login to my site
问题描述
我测试过上使用随手机附带的通用浏览器2型号的手机我的网站,但可悲的是,每次我试图登录,就会返回我回到我的索引页。
i've tested my site on 2 phone models using the 'generic' browser that came with the phone, but sadly, everytime I tried to login, it will return me back to my index page.
这是我的登录code
here's my login code
<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(片段)
and here's the authentication.php (snippet)
$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的支持(至少这是浏览器设置所说的话)。
The only way I can access my mobile site is by using opera mini. Just FYI, both the 'generic browsers' i tested my site with supports cookie (at least this is what the browser settings said).
感谢
推荐答案
一些移动浏览器(黑莓春记)不处理任何事情,但2xx应答发送的cookie - 您正在使用302重定向响应。
Some mobile browsers (Blackberries spring to mind) don't process cookies sent in anything but a 2xx response - you are responding with a 302 redirect.
试试这个:
setcookie("currentMobileUserName", $currentUserName, $expire);
setcookie("currentMobileUserEmail", $currentUserEmail, $expire);
setcookie("currentMobileSessionID", $getGeneratedMobileUSID, $expire);
setcookie("currentMobileUID", $currentUID, $expire);
$userIsLoggedIn = "YES";
$registeredUser = "YES";
... // some WML/HTML markup...
print "You are logged in. Click <a href='"
. $config['MOBILE_URL']. "/home.php'>here</a> to continue.";
此外,一些老设备不喜欢抱着每个站点多个cookie - 解决这个一个是一个比较复杂一点假设你想提供一个永久标识符,这样用户不必登录(你生成自己的会话ID加密标识与时间的用户,并设置在未来的到期时间的标记 - 如果没有会话ID找到匹配,解密获得记得我值)
Also, some older devices don't like to hold more than one cookie per site - solving this one is a bit more complicated assuming that you want a persistent identifier available so the user doesn't have to log in (generate your own session id encrypting a token which identifies the user with the time and set an expiry time in the future - if no session id is found matching, decrypt to get the remember me value).
℃。
这篇关于移动浏览器“无法登录到我的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!