note 55239 added to ref.session

From: Date: Thu, 28 Jul 2005 11:33:48 +0000
Subject: note 55239 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-92625@lists.php.net to get a copy of this message
Another note about session.bug_compat_42 and bug_compat_warn. [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['var'] = NULL; $var = "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['var'] contains NULL and you assign anything (except NULL) to the global variable $var. The warning will _not_ appear: - if $_SESSION['var'] contains anything else - or - - if you don't use a global variable named $var ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55239 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55239&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55239&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92625) next »