Home > General > 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.

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

Categories: General
  1. alex
    October 17, 2007 at 9:03 pm | #1

    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.

  2. Jeyaprakash
    November 29, 2007 at 12:55 pm | #2

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

  3. Mikael
    February 22, 2008 at 10:56 am | #3

    Thanks, This was really helpful. It allowed me to be sure that we could safely turn these warnings off.

  4. jaccob
    April 9, 2008 at 8:48 am | #4

    million of thanks from spain

  5. April 22, 2008 at 1:40 am | #5

    I managed to get the same error, simply using a construction like this under PHP v5.2.1:

    $pwd = $_SESSION['pwd'] ? $_SESSION['pwd'] : 'empty';

    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!

  6. tay
    April 27, 2008 at 2:21 am | #6

    Thanks. You saved my butt.
    Alex’s comment :I just set the session var to “” instead of NULL.
    was very helpful to me too.

  7. January 1, 2009 at 3:16 am | #7
  8. Iluvalar
    April 19, 2009 at 3:55 pm | #8

    Yeah, thanks. It saved me some headhach.

  9. Marek
    July 26, 2009 at 12:15 pm | #9

    Thanks a lot! Had the same problem today. :-)

  10. token
    February 19, 2010 at 8:58 pm | #10

    … and thanks a lot from Germany.

  11. ng
    March 21, 2011 at 11:12 am | #11

    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

    • preetul
      March 23, 2011 at 4:57 am | #12

      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,

  12. preetul
    April 25, 2009 at 5:27 am | #13

    Hey buddy…I wld appreciate if you post your own experience as by this time you must have understood the purpose the blog.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.