session does not carry out all the other pages after being set ?

Posted on 2003-03-23
Medium Priority
Last Modified: 2006-11-17
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>");
   { 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 :

     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");
          else {
               $error_msg="Invalid User-ID/Password";

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 ?
Question by:edmondlim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 15

Expert Comment

ID: 8190581
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']=


Expert Comment

ID: 8190634
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)
LVL 15

Expert Comment

ID: 8190672
that's what I said :D

anyway, superglobals not being global do annoy me 8-)
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.


Accepted Solution

bobsledbob earned 300 total points
ID: 8192810

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


Author Comment

ID: 8193662
That was missing, session_start(); in member.php SSI, thanks bobsledbob.
LVL 15

Expert Comment

ID: 8194441
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-)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question