edmondlim
asked on
session does not carry out all the other pages after being set ?
I've this member.php script as a SSI.
if (session_is_registered('ui d')) {
$uid = $_SESSION["uid"];
echo ("<tr><td valign=top class=normal><br><i>Welcom e $uid</i></td></tr>");
}
else
{ require ('logon.php'); }
The logon.php is a form input of userid & password.
In the beginning of every page on my site, I call require ('auth.php') and here's the script :
<?php
session_start();
if(isset($logon)) {
$sql = "SELECT * FROM profile WHERE userid = '$userid' AND password = '$password'";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num > 0) {
$uid = mysql_result($result,0,"us erid");
session_register("uid");
}
else {
$error_msg="Invalid User-ID/Password";
}
mysql_free_result($result) ;
}
?>
Somehow, the session "uid" was set and able to display the message welcome $userid everytime I've logon through the form. After that, when I clicked on other pages which include the member.php as SSI, it always goes into the "require ('logon.php');" section. It seems like it does not register at all. Can anybody tell me what am I missing ?
if (session_is_registered('ui
$uid = $_SESSION["uid"];
echo ("<tr><td valign=top class=normal><br><i>Welcom
}
else
{ require ('logon.php'); }
The logon.php is a form input of userid & password.
In the beginning of every page on my site, I call require ('auth.php') and here's the script :
<?php
session_start();
if(isset($logon)) {
$sql = "SELECT * FROM profile WHERE userid = '$userid' AND password = '$password'";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num > 0) {
$uid = mysql_result($result,0,"us
session_register("uid");
}
else {
$error_msg="Invalid User-ID/Password";
}
mysql_free_result($result)
}
?>
Somehow, the session "uid" was set and able to display the message welcome $userid everytime I've logon through the form. After that, when I clicked on other pages which include the member.php as SSI, it always goes into the "require ('logon.php');" section. It seems like it does not register at all. Can anybody tell me what am I missing ?
Using predefined variables also known as superglobals such as $_SESSION are preferred since 4.2.0 (External variables are no longer registered in the global scope by default, register_globals off by default)
that's what I said :D
anyway, superglobals not being global do annoy me 8-)
anyway, superglobals not being global do annoy me 8-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was missing, session_start(); in member.php SSI, thanks bobsledbob.
tsss tsss tsss you wrote "In the beginning of every page on my site [I include a session_start; in a required file]"
too easy answer 8-)
too easy answer 8-)
in this situation, it is not recommended to session_register() session variables, but in stead to do $_SESSION['uid']=
regards