I'm working on a login sequence for a site, and for some reason or another, I'm having some problems getting session variables to register and be accessible. I had some problems registering the username for a while, but when when I stopped trying to pass the name into another variable, it worked. (E.g. Originally I was saying $newusername=$oldusername, then registering $newusername to add a bit of security. When I did that though, the variable registered empty. When I just registered $oldusername, it worked fine.) Here's the problem function:
function login($oldusername, $oldpassword)
// check username and password with db
// if yes, return true
// else return false
{
// connect to db
db_connect();
// check if username a
$result = mysql_query("select * from themembers where handle='".$oldusername."' and pass=password('".$oldpassword."')");
$userArray=mysql_fetch_assoc($result);
if (!$result)
return 0;
extract($userArray);
$currenttime=mktime();
if (mysql_num_rows($result)>0 && $expire>$currenttime)
{
session_register("oldusername");
session_register("user_type");
return 1;
}
else
return 0;
}
The problem isn't that the session is not registering - They can log in, and the session will be registered - but that, for whatever reason, the user_type variable is registering as "" -- blank. Oh, and I can echo back user_type within that function and it works. The variable really exists, and it's full.
Any ideas?