I am trying to write two php scripts to handle the login on a website. The first one ends like this:
Code: Select all
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
//echo "Username: " . $_SESSION['username'];
header("location:login_success.php");
The beginning of login_success.php looks like this:
Code: Select all
<?
session_start();
if(!isset($_SESSION['username'])){
header("location:[Failed Relocation]");
}
echo "Username: " . $_SESSION['username'];
//session_destroy();
?>
Originally this code worked, but then I had a problem with a different username not replacing the first username used in $_SESSION. So I added session_destroy(); at the end of login_success.php, only after that $_SESSION['username'] always returned empty when I used echo. I commented out session_destroy(), as you can see, but ever since then, isset() has been returning false and I have been redirected to [Failed Location] every time.
Can anyone lend me some insight into what is going on?
PS: The version of PHP I'm using is 5.2.9