这是php会话问题..用户可以多次登录..在同一个浏览器上使用相同/不同的凭据..
1)用户1登录..
2)User1尝试在新标签中打开LoginIndex.php ..
3) 它显示的是 LoginIndex.php 页面,而不是以前登录的页面(用户 1 登录)...
4) 接受 User1 使用相同/不同的凭据再次登录 .. 在同一浏览器中
我不知道为什么它再次使用登录值..
这是 LoginViewController.php 的片段
<?php
if (!isset($_POST['submit']))
{
?>
<html>
<table align="center">
<tr>
<td>
<input class="input" type="text" name="uname" id="uid" placeholder="Username" >
</td>
</tr>
<tr>
<td>
<input class="input" type="password" name="pwd" id="pid" placeholder="Password" >
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="" > </td>
</tr>
</table>
<?PHP
}
else
{
//If you are submitting the form insert the details into database
$Username = $_POST['uname'];
$Password = $_POST['pwd'];
session_start();
If (!(empty($Username) && empty($Password)))
{
$model = new UsersModel();
$rowsCount = $model->checkUser($Username,$Password,$User_Type);
if ($rowsCount!=0)
{
$_SESSION['user'] = $Username;
header("location:loggedin.php");
} else
{
echo '<script type="text/javascript">alert("Enter username and password correctly");
window.location.href="LoginViewController.php";</script>';
}
}
}
?>
这是我正在处理的login-in.php代码...
<?php
header("Cache-Control: private, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Fri, 4 Jun 2010 12:00:00 GMT");
include('GenericClasses/GenericCollectionClass.php');
include('Models/UsersModel.php');
include('DataObjects/Users.php');
include('DatabaseAccess/DBHandler.php');
session_start();
if(!isset($_SESSION['user']))
{
header('Location: LoginViewController.php');
exit();
}
echo '"<div style="background:white; text-align:right"> Login as:'.$_SESSION['user'].'
<a href="LogoutViewController.php" style="text-align:right">Logout</a></div>"';
?>
任何建议都可以接受...