It's php session problem.. where user's can login multiple times.. on same browser with same/different credentials..
1) User1 logged in ..
2) User1 Try to open LoginIndex.php in new tab..
3) It's showing the LoginIndex.php page instead of Previous Logged in page(User1 logged in)...
4) Accepting the User1 to login again with same/different credentials.. in same browser
I don't know why it is taking the login values again..
Here is the snippet of 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>';
}
}
}
?>
Here is the logged-in.php code that what i am working on it...
<?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>"';
?>
Any suggestions are acceptable...