Forum Moderators: coopster

Message Too Old, No Replies

session side-effect which existed until PHP 4.2.3 - Fixed

         

OfficeTech

5:55 am on Mar 3, 2009 (gmt 0)

10+ Year Member



We had just come across this problem with a particular website we are developing and believe that we know of the main cause as we have never received this error before and try to test most limits on development.

The Problem Code:


<?php
$orderItem = $_SESSION["orderItem"];
$orderPrice = $_SESSION["orderPrice"];
?>

The Fixed Code:


<?php
$SorderItem = $_SESSION["orderItem"];
$SorderPrice = $_SESSION["orderPrice"];
?>

Basiclly we have until now used the exact same name for a session variable in this way, But seems this was the cause of the error for us.

Hope this helps a few people around?

blang

6:05 am on Mar 3, 2009 (gmt 0)

10+ Year Member



Hi 'OfficeTech'. Not sure what to make of your post. Both code segments you've posted are syntactically correct and identical with the exception of the variable names... I would assume this is something innate to your application and not PHP related.

OfficeTech

6:21 am on Mar 3, 2009 (gmt 0)

10+ Year Member



When we first stumbled upon this error, We had a quick google as we all do and noticed that there was alot of people who could not find an answer for this error and were simply turning of the warning in the php.ini file instead which is not a safe option at all.

-------------The Error-------------
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.
-----------------------------------

In the previous post, It shows that if you have your variable named the exact same as the session variable then it will see it as a false global register.

The previous code also can be used as an example on how to reproduce the error for demonstration purposes.

One previous posting that had this issue or the same error was [webmasterworld.com...] but the post is to old to reply to, So figured we would produce this one and if anyone else has issues then we shall do our best to help out.

coopster

4:23 pm on Mar 3, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What version of PHP are you running and on what platform? Also, please show the values you have set on your server for the following PHP configuration directives:
register_globals [php.net] 
session.bug_compat_42 [php.net]
session.bug_compat_warn [php.net]