ID: 19760
User updated by: [EMAIL PROTECTED]
-Summary: _some_ Session variables isnt registered.
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Closed
-Bug Type: Session related
+Bug Type: Unknown/Other Function
Operating System: WinXP
PHP Version: 4.2.3
New Comment:
works..
Previous Comments:
------------------------------------------------------------------------
[2002-10-04 15:39:38] [EMAIL PROTECTED]
changed the summary.
------------------------------------------------------------------------
[2002-10-04 15:34:00] [EMAIL PROTECTED]
Hello.
I got a 4-5 diffrent scripts that I use on a page to login on my site
(db functions, general functions, login functions, html header/footer
and loginpage).
When I login everything works fine except some session variables doesnt
register.
I've used a die($_SESSION["url"]); right before the
Header("startpage.php"); and the string prints correct. When I remove
the die and put it on the first line in startpage.php it complains on
"Notice: Undefined index: url in
E:\projects\inetpub\cl4\user\startpage.php on line 3"
I've tried so reproduce the error on a more slim page without success.
These session variables are set ok:
$_SESSION["email"] = $rs["email"];
$_SESSION["userid"] = $rs["userid"];
$_SESSION["nickname"] = $rs["nickname"];
$_SESSION["gameid"] = 1;
$_SESSION["modid"] = 1;
the variables in user_admin_flags_get() and user_teams_get() are not
set.
login functions (user_login is called from the submit):
function user_login($email, $password)
{
//Check if the activationcode match the saved one
$sql = "SELECT userid FROM user_info WHERE
email='".addslashes($email)."' AND
password='".addslashes($password)."'";
if (!$userid = db_execute_scalar($sql))
{
$GLOBALS["errormsg"] = "Incorrect email/password.";
return false;
}
return user_login_userid($userid);
}
function user_login_userid($userid)
{
$sql = "SELECT userid,email,status,nickname FROM user_info WHERE
userid=$userid";
if (!$resid = db_query($sql))
{
$GLOBALS["errormsg"] = "Failed to query the database ( $sql ).";
return false;
}
//Fetch the row
if (!$rs = db_fetch_row($resid))
{
$GLOBALS["errormsg"] = "Invalid/deleted userid.";
return false;
}
if ($rs["status"] <= 0)
{
$GLOBALS["errormsg"] = "You're account are locked / You have not been
validated.";
return false;
}
$_SESSION["email"] = $rs["email"];
$_SESSION["userid"] = $rs["userid"];
$_SESSION["nickname"] = $rs["nickname"];
$_SESSION["gameid"] = 1;
$_SESSION["modid"] = 1;
user_admin_flags_get($userid);
user_teams_get($userid);
return true;
}
//fetch adminflags for the user
function user_admin_flags_get($userid)
{
//Check if the activationcode match the saved one
$sql = "SELECT * FROM user_admin WHERE userid=$userid";
if (!$resid = db_query($sql))
{
$GLOBALS["errormsg"] = "Failed to query the database ( $sql ).";
return false;
}
//set nada
if (db_eof()) {
$_SESSION[0][0] = 0;
return;
}
//set all flags
while (!$rs = db_fetch_row($resid))
{
$_SESSION[$rs["modid"]] = $rs["flags"];
}
//Set all nonexisting modflags to 0
for ($a = 1; $a < MOD_COUNT; $a++)
{
if (!isset($_SESSION[$a]))
$_SESSION[$a] = 0;
}
return true;
}
//fetch teams for the user
function user_teams_get($userid)
{
//Check if the activationcode match the saved one
$sql = "SELECT ti.teamid, ti.name, tu.status FROM team_user tu,
team_info ti WHERE ti.teamid=tu.teamid AND tu.userid=$userid AND
tu.status>0";
if (!$resid = db_query($sql))
{
die($sql);
$GLOBALS["errormsg"] = "Failed to query the database ( $sql ).";
return false;
}
$_SESSION["url"] = '<a class="ff"
href="../user/startpage.php">mypage</a> ';
//Build a teamurl here
//=======================================================
if (db_eof()) {
die("TEAM EOF");
return true;
}
//Fetch all teams that the user is a member in.
$a = 0;
while ($rs = db_fetch_row($resid))
{
$_SESSION["url"] .= ' | <a class="ff"
href="../team/myteam.php?teamid='.$rs["teamid"].'">'.$rs["name"].'</a>
';
//$_SESSION["teamname"][$a] = $rs["name"];
$_SESSION["teamstatus"][$rs["teamid"]] = $rs["status"];
$a++;
}
$_SESSION["teamcount"] = $a;
return true;
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=19760&edit=1