Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

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('uid')) {
   $uid = $_SESSION["uid"];
   echo ("<tr><td valign=top class=normal><br><i>Welcome $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,"userid");
                     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 ?
0
edmondlim
Asked:
edmondlim
1 Solution
 
VGRCommented:
i suppose you've register_globals=off in your php.ini because you use $_SESSION[]

in this situation, it is not recommended to session_register() session variables, but in stead to do $_SESSION['uid']=

regards
0
 
KriekCommented:
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)
0
 
VGRCommented:
that's what I said :D

anyway, superglobals not being global do annoy me 8-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
bobsledbobCommented:

In your member.php SSI, are you calling the function session_start() ??  Just making sure. ;)

0
 
edmondlimAuthor Commented:
That was missing, session_start(); in member.php SSI, thanks bobsledbob.
0
 
VGRCommented:
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-)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now