PHP Session Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

PHP Session Error

Post by YoussefSiblini »

Hi,
I want to change error reporting to not show warnings, since I am getting this error:

Code: Select all

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0
How can I do that please, I have tried to do it from this link http://us2.php.net/manual/en/function.e ... orting.php, but I am quit newb with this and I couldn't find how to do it :)


Youssef
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: PHP Session Error

Post by flying_circus »

Can you post some of your code?

It is easy to tell you how to disable those errors, but that isn't necessarily the "correct" answer. Simply disabling the errors is a bit like the ostrich syndrome, burying your head in the sand.

Where are you setting session variables and where are you using $GLOBAL or global?
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: PHP Session Error

Post by YoussefSiblini »

Thank you,
Here is the php code:

Code: Select all

<?php 
// headers change between logged in and not logged in
session_start();
$header = '';
date_default_timezone_set('Europe/London');  
$thisDay = date('l jS \of F Y h:i:s A');
$topBoxes = '';
if (!isset($_SESSION["manager"])) {
     $header ='includes/header.php';
}
else
{
     // Be sure to check that this manager SESSION value is in fact in the database
     $managerID = $_SESSION["id"]; 
     $IEmail =  $_SESSION["manager"];
     $pass = $_SESSION["password"];
     include 'includes/connect_users.php';  
     $sql = mysql_query("SELECT * FROM members WHERE id ='$managerID' AND Email ='$IEmail' AND Password='$pass' LIMIT 1"); 
     $existCount = mysql_num_rows($sql); // count the row nums
     if ($existCount == 0) 
     { 
   
       $header ='includes/header.php';
     }
     else
     {
	      while($row = mysql_fetch_array($sql))
	  	  {
          $User_name = $row["User_name"];
          $header = 'includes/header_Secure.php';
	      }
     }
}
?>

Youssef
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: PHP Session Error

Post by flying_circus »

I can't spot any errors in this piece of code, that would trigger the error you are receiving. I would check in the rest of your included files as well.

You can use ini_set() to change the values of the directives mentioned in your error message

Code: Select all

ini_set('session.bug_compat_42', 0);
ini_set('session.bug_compat_warn', 0);
YoussefSiblini
Forum Contributor
Posts: 206
Joined: Thu Jul 21, 2011 1:51 pm

Re: PHP Session Error

Post by YoussefSiblini »

What do I have to do with this code exactly? put it in ini.php and under the public_html folder?


Youssef
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: PHP Session Error

Post by flying_circus »

Try placing it in your .php file right before your session_start() call.
Post Reply