How to create simple Member Login for your websites. Part 2 - Session Management

Part 2 - Managing Sessions
OK now we have the user logged in how do we keep them logged in while they are going between pages in the members area/admin area.
Simple all we need to do is include this small piece of code right at the first line of every page.
<?php
session_start();
// is the one accessing this page logged in or not?
if (!isset($_SESSION['admin_loggedin'])
|| $_SESSION['admin_loggedin'] !== true) {
// not logged in, move to login page
header('Location: index.php');
exit;
}
?>
Notice we start the session once again and check to see if they are logged in and kick them back to the index.php page if there not and if they are logged in we leave them to use the page they are viewing.
That's all there is to managing sessions.
Next Page - Logging out users
Back to the start
Comments
Comments will be displayed here
Contact Me
If you would like to contact me, the easiest and quickest way to do so is by filling out the contact form on this website.
If you prefer you can contact me on any of these Websites:







