The first thing at the start of every page is "session_start()". Next, each page has the following code. The 'loggedIn' session variable was initialized to 0 with a require_once call of another script. When you log in, the page that did the check will show the login is successful, but navigate to any other page (even reload the current one) and you're no longer logged in. What's missing?
if (isset($_POST['usernameField']) && isset($_POST['passwordField']) && ($_SESSION['loggedIn']==0)){
if (!empty($_POST['usernameField']) && !empty($_POST['passwordField'])){
//Connect to the MySQL database server
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to database');
//Connect to the specified database
mysql_select_db($dbname);
$sql = sprintf("SELECT FirstName FROM tblCustomers WHERE UserName = '%s' AND Password = md5('%s')",
mysql_real_escape_string($_POST['usernameField']),
mysql_real_escape_string($_POST['passwordField']));
$result = mysql_query($sql);
if ($row = mysql_fetch_array($result)){
session_start();
session_register($_POST['usernameField']);
$_SESSION['loggedIn'] = 1;
$_SESSION['Name'] = $row['FirstName'];
}else{
$_SESSION['loggedIn'] = 0;
$_SESSION['Name'] = '';
}
unset($_POST['usernameField']);
unset($_POST['passwordField']);
}
}