views:

2771

answers:

3

I'm trying to host a PHP web site that was given to me. I see this warning:

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

What does this mean? How might I track down the source of this problem within the code?

+8  A: 

basically you have a variable with the same name as your session. ex:

$_SESSION['var1'] = null;
$var1 = 'something';

which will reproduce this error. you can stop PHP from trying to find existing variables and warning you about them by adding these lines to your script:

ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);

these values can be set in php.ini or .htaccess as well

Owen
I came here today with this exact question, found this question on my first search attempt, and found your perfectly clear and comprehensive solution to my problem (duplicate variable names). +1 to you good sir!
Andrew Heath
+1  A: 

thanks for your code. one problem solved in my project.

why the problem occured. could u tell me ? my mail id : [email protected]
+1  A: 

I interpret this php bug content: http://bugs.php.net/bug.php?id=41540 to mean that this error may also occur when you assign a variable to the session superglobal that is not yet initialized, e.g.

//Start of script
$_SESSION['bob'] = $bob;

I may be wrong, but it's another possibility to watch out for.

Tchalvak