Problems with sessions...
Posted: Mon Dec 23, 2002 7:36 am
I am working on a user authentication system and so far I have the following:
And in a second file I have:
The output I am expecting to get when someone is logged in (me for example) is:
I also can not access any of the variables that should be stored in the array. I have tried using $HTTP_SESSION_VARS["login"] = $login; and tried calling them back using $HTTP_SESSION_VARS as well, but that didn't seem to work either...
PHP Version is 4.0.1pl2, globals are on...*hangs his head*
Thanks for any help you may provide.
Code: Select all
<?
if ($submital == "submit") {
$connection = mysql_connect("$host","$sqluser","$pass");
if ($connection == false) {
echo mysql_errno . ": " . mysql_error() . "<br>";
exit;
}
mysql_select_db('kidstop');
$query = "SELECT * FROM staff WHERE u_name = '$name'";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result)) {
if ($name == $row["u_name"]) {
if (md5($pass1) == $row["u_pass"]) {
$login = mysql_fetch_array($result);
session_register("login");
echo "<BR>You are now logged in as ".$row["u_name"]." with a user level of ".$row["u_level"]."!\r\n";
} else { // pass
echo "<BR>Unable to login at this time!<BR> Bad Password!";
}
} else {
echo "<BR>Unable to login at this time!<BR> Bad Name!"; // name
}
} else {
echo "<BR>Unable to login at this time!<BR> No Result!"; // result
}
} else {
echo "<BR>Unable to login at this time!<BR> Nothing submitted!"; // submitted
}
?>Code: Select all
<?
if ( $login ) {
echo "Found Login Session!!!!!<BR>";
} else {
echo "Can not find login session as \$login!!!!!<BR>";
}
if ( session_is_registered('login'))
echo "Welcome back ".$u_name."!<BR>";
else
echo "Session not registered!<BR>";
?>Instead what I am getting is:Found Login Session!!!!!
Welcome Back Elmseeker!
Code: Select all
Can not find login session as $login!!!!!
Welcome back !PHP Version is 4.0.1pl2, globals are on...*hangs his head*
Thanks for any help you may provide.