Martin Laing - Multimedia Developer | Fife, Scotland

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

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

Back to Tutorial Home

Latest Projects

Fallen Angels Website Development Bucketball Candy Drop Fallen Angels Bebo Application Hector the Inspector

View Full Portfolio


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.

Send Me a Message

If you prefer you can contact me on any of these Websites:


Bebo facebook Myspace Twitter

Tutorials


How to send data from Flash to PHP How to create a Contact Form using PHP How to create simple Member Login for your websites. Part 1 - Member Login How to create simple Member Login for your websites. Part 2 - Session Management How to create simple Member Login for your websites. Part 3 - Logging Out Users