PHP session side-effect warning
by Guna[ Edit ] 2012-06-14 12:08:45
Hi,
Some times you may have come accross warning like this one:
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
This warning means, you've named a variable same name as your session!.
Have a look at the following ex:
$_SESSION['var1'] = null;
$var1 = 'something';
The above will reproduce the warning because you already have a session name
var1 and in following line you've named a variable as
var1. It is a good practise not to name a variable like this, however you can turn off this warning by adding following code to your script:
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);