I have a web site that requires users to log in and then after the log in, depending in which table of a mysql users DB they will be directed to a relevant Main Page.
I use a piece of code that shows who is logged and if they form part of the CKS users it will add a href to the list which is only available to the CKS users and not the rest....it was to save some coding time:
Code: Select all
<td valign="top" align="center">
<?php echo "You are logged in as <b>". $_SESSION['logged_in'] ."</b>" ?></br>
</br>
<table id="nav" cellspacing="0" border="1" valign="top" width="100%">
<tr id="nav"><td><a href="bwmain.php">Builders Warehouse</a></td></tr>
<tr id="nav"><td><a href="wcmain.php">Builders W/Cape</a></td></tr>
<tr id="nav"><td><a href="bxmain.php">Builders Express</a></td></tr>
<?php
$cks = $_SESSION['cks'];
if ($cks !== 1) {} else {
echo"<tr id=\"nav\"><td><a href=\"cksmain.php\">CKS Main Page</a></td></tr>"; }
?>
<tr id="nav"><td><a href="main.php">HOME</a></td></tr>
<tr id="nav"><td><a href="logout.php">LOG OUT</a></td></tr>
</table><
Code: Select all
?php
session_start();
if ($_SESSION['basic_is_logged_in'] != true) {
header("location: index.php");
}
?>I've searched a couple of sites but they only explain how to do what I've done thus far but not what or how to make sure that a new session is created for every user that logs in eliminating the session of the user logged in first be overwritten by a session of a user that logs in after the first user.
How or what should I add to ensure that a separate session is created for every user. I have table in a DB that tracks user actions and is dependent on the $_SESSION['logged_in'] to populate the USer Name.
Thank you in advance