SESSION problem
Posted: Wed Jan 13, 2010 5:35 pm
I have something not working 
When a user logs in, I call authenticate.php and in that file is the following code that runs if the user enters a valid username/password:
Over in index.php I have the following:
So, if the session variable is set, I get a message saying I logged in. If not, I get the login boxes.
My problem is, the first branch of the if statement is not running, meaning the session is not being set (?), but I'm setting it in authenticate.php right before it refreshes back to index.php. What am I missing here?
When a user logs in, I call authenticate.php and in that file is the following code that runs if the user enters a valid username/password:
Code: Select all
$_SESSION['player_name']=$playername;
echo "<center>You are now logged in $playername. Have fun!<br></center>";
header('Refresh: 2; URL=index.php');
exit;
Code: Select all
if (isset($_SESSION['player_name']))
{
$playername = $_SESSION['player_name'];
echo "$playername logged in";
}
else
{
include 'login.php';
}
My problem is, the first branch of the if statement is not running, meaning the session is not being set (?), but I'm setting it in authenticate.php right before it refreshes back to index.php. What am I missing here?