I already tried that, yes. It still keeps my session.
I'm going to try
$_SESSION["authenticationValid"] = FALSE;
$_SESSION["authenticationUser"] = "";
instead to see if that works.
EDIT: Didn't work. Here are all my pages and their respective content.
index.php
<?php
session_start();
if(!isset($_SESSION["authenticationValid"]) || $_SESSION["authenticationValid"] !== TRUE)
{
header("Location: login.php");
exit;
}
?>
<HTML>
<HEAD>
<TITLE>Welcome to our secured home page!</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
</HEAD>
<BODY>
<P>Welcome, <STRONG><?php echo $_SESSION["authenticationUser"]; ?></STRONG>!</P>
<P><A HREF="logout.php">Logout</A></P>
</BODY>
</HTML>
login.php
<?php
session_start();
$mysqlHost = "localhost";
$mysqlUserName = "newacct";
$mysqlPassWord = "***********";
$mysqlDatabase = "newacct_1";
$mysqlConnect = mysql_connect($mysqlHost, $mysqlUserName, $mysqlPassWord);
$mysqlSelect = mysql_select_db($mysqlDatabase);
if(isset($_POST["submit"]))
{
if($_POST["userName"] != "" && $_POST["passWord"] != "")
{
$mysqlQuery[1] = mysql_query("SELECT 'userName' FROM authentication_system WHERE userName = '".$_POST["userName"]."' AND passWord = PASSWORD('".$_POST["passWord"]."');");
if(mysql_num_rows($mysqlQuery[1]) == 1)
{
$_SESSION["authenticationValid"] = TRUE;
$_SESSION["authenticationUser"] = $_POST["userName"];
header("Location: index.php");
}
else
{
$displayMessage = "The username/password combination you entered was incorrect.";
}
}
else
{
$displayMessage = "Please enter a value in both login fields!";
}
}
?>
<HTML>
<HEAD>
<TITLE>PHP/MySQL Authentication System</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
</HEAD>
<BODY>
<P><?php echo $displayMessage; ?></P>
<FORM ACTION="" METHOD="POST">
<TABLE>
<TR>
<TD ALIGN="center">Username</TD>
<TD ALIGN="center"><INPUT TYPE="text" NAME="userName" VALUE="<?php echo $_POST["userName"]; ?>"></TD>
</TR>
<TR>
<TD ALIGN="center">Password</TD>
<TD ALIGN="center"><INPUT TYPE="password" NAME="passWord"></TD>
</TR>
<TR>
<TD COLSPAN="2" ALIGN="center"><INPUT TYPE="submit" NAME="submit" VALUE="Login"></TD>
</TR>
</TABLE>
</FORM>
<P>© Copyright 2008 lupus6x9.</P>
</BODY>
</HTML>
logout.php
<?php
$_SESSION["authenticationValid"] = FALSE;
$_SESSION["authenticationUser"] = "";
?>
Thanks for logging out! <A HREF="index.php">Go to the home page now.</A>