?
Solved

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

Posted on 2003-03-23
6
Medium Priority
?
235 Views
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>");
}
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
Comment
Question by:edmondlim
[X]
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
6 Comments
 
LVL 15

Expert Comment

by:VGR
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']=

regards
0
 
LVL 1

Expert Comment

by:Kriek
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)
0
 
LVL 15

Expert Comment

by:VGR
ID: 8190672
that's what I said :D

anyway, superglobals not being global do annoy me 8-)
0
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.

 
LVL 2

Accepted Solution

by:
bobsledbob earned 300 total points
ID: 8192810

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

0
 

Author Comment

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

Expert Comment

by:VGR
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-)
0

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