Hi,
I have some scripts to authenticate users via a database. When the user is authenticated and passed back to another page, I cannot retrieve the session variables that should have been set - so either they are not being set or cannot be retrieved.
Can someone please advise on the problem?
Here is the main part of the code which should set the session variables:
session_start();
//Then some more code to set the value of $authenticated
if ($authenticated == true)
{
//print "Authentication made";
// Register the customer id
session_register("authenticatedUser");
$authenticatedUser = $appUsername;
// Register the remote IP address
session_register("loginIpAddress");
$loginIpAddress = $REMOTE_ADDR;
}
else
{
// The authentication failed
//print "Authentication failed";
session_register("loginMessage");
$loginMessage =
"Could not connect to the winestore " .
"database as \"$appUsername\"";
}
//Relocate back to the login page
header("Location: login.php");
Here is the main part of the code to retrieve the session variables in login.php :
// Main
session_start();
// Check if we have established a session
if (isset($HTTP_SESSION_VARS["authenticatedUser"]))
{
print "User logged on";
// There is a user logged on
logged_on_page(
$HTTP_SESSION_VARS["authenticatedUser"]);
}
else
{
print "No session established";
// No session established, no POST variables
// display the login form + any error message
login_page($HTTP_SESSION_VARS["loginMessage"]);
session_destroy();
}
It is not recognising values of the authenticatedUser or loginMessage variables.
Thanks,
Hal.