(I had posted this in General Help, but decided that this forum might be more appropriate... I deleted the original thread)
Hello, I am wondering if someone could give me comments/suggestions on how to set up a website with multiple sections for people to log in to, each having its own table of users. While I'd prefer to use just one table, I have to work with an existing database.
For each section, I check the username/password against the database, and if it matches, I set the session variables, and forward them to the logged in page.:
[code=php]
if ($row) {
session_start();
$_SESSION['first_name'] = $row[1];
$_SESSION['admin_id'] = $row[0];
header ("Location: <a href="http://" target="_blank">[url]http://[/url]</a>" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/loggedin.php");
exit();
}
[/code]
I check for login by seeing if the appropriate session variable (the id of the entry from the user table) have been set:
if(!isset($_SESSION['admin_id'])){
header ("Location: <a href="http://" target="_blank">[url]http://[/url]</a>" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/notloggedin.php");
exit();
}
While my code seems to work ok, I'm wondering if there is a better way for me to do this. Are there any major problems with how I have it set up? My biggest issue is that when the user logs out, the session is destroyed, logging him or her out of everything.
Thanks