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.
[full error message:
"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."
]
The following short script causes the bug_compat_42 warning to appear.
<?php
session_start();
$_SESSION['userId'] = NULL;
$userId = “foo”;
?>
It took me an hour to find out this
– so I post it here to avoid
that more people need such a long time.
Conclusion and test results:
You’ll get this warning if $_SESSION['userId'] contains NULL and you assign
anything (except NULL) to the global variable $var.
The warning will _not_ appear:
- if $_SESSION['userId'] contains anything else – or -
- if you don’t use a global variable named $userId
Thanks for the tip. The bug just popped up on me today, and all of the pages I found with this warning message were because of people using session_register().
I had the same problem as you though, and it was pretty hard to track down. In the first execution of a page, my session var would be empty and I’d get the warning, and in the second, the session var would have what seemed to be random data. So on and so on.
Anyway, thanks again. I just set the session var to “” instead of NULL.
Hi friend,
Thank you sooo much for the tip. It saved me from a lot of coffee and headache and infact lot of frustrations. Thanks for your wonderful experienced advice.
Thanks soo much..
Thanks, This was really helpful. It allowed me to be sure that we could safely turn these warnings off.
million of thanks from spain
I managed to get the same error, simply using a construction like this under PHP v5.2.1:
The fix was to change the name of the target variable from $pwd to a different string, like $passwd or $pass. Thanks for your help!
Thanks. You saved my butt.
Alex’s comment :I just set the session var to “” instead of NULL.
was very helpful to me too.
thank u very much…kind regard
Yeah, thanks. It saved me some headhach.
Thanks a lot! Had the same problem today.
… and thanks a lot from Germany.
i have this problem
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 fix it?
my code is
ng, I would appreciate if u can send me the exact code u r trying to compile.
Also let me know which PHP Version u r using.
regards,
Hey buddy…I wld appreciate if you post your own experience as by this time you must have understood the purpose the blog.