Here is my situation involving "login2.php" and "index.php".
I have a script, login2.php, which processes a log in and then assigns session variables. If you log in successfully, it sets a session variable.
So login2.php sets the variables correctly as evidenced by a quick:
print_r($_SESSION);
I can see the variable sitting there in the array. The problem is, when the user uses the menu on that page (of successful login) to go to the main page (or any page really) ... suddenly the $_SESSION array is empty. (Yes, I used the session_start() on all pages.)
So in "index.php":
print_r($_SESSION);
returns an empty array.
What the hell is going on here? They are there one minute, and the second you navigate away from a page, they are gone. Dear Lord.
Here are the meaningful segments.
login2.php:
session_start();
...
$_SESSION["ML_LoggedIn"] = "TRUE";
...
print_r($_SESSION);
index.php:
session_start();
...
if ($_SESSION["ML_LoggedIn"] != "") {
print("Logged in.");
} else {
print("NOT logged in.");
}
...
print_r($_SESSION);
As I mentioned, index.php always returns "NOT logged in" and an empty array set for $_SESSION.
Can anyone help me? I'm about to lose it here!
I know about the header("Location...") bug, and since I'm not using that, that isn't the problem 🙂