PHP 4.0 Bug #8315: strange session behavior with register_globals off

From: Date: Mon, 18 Dec 2000 18:02:24 +0000
Subject: PHP 4.0 Bug #8315: strange session behavior with register_globals off
Groups: php.dev 
Request: Send a blank email to php-dev+get-41802@lists.php.net to get a copy of this message
From: cynic@mail.cz Operating system: NT 5 SP 1 PHP version: 4.0 Latest CVS (18/12/2000) PHP Bug Type: *Session related Bug description: strange session behavior with register_globals off Apache 1.3.14 through apache-1.3_20001218111201 PHP snapshots since about two weeks ago through php-4.0.4RC6 stock php.ini-optiomized (with the exception of error_reporting E_ALL) Actually I cannot confirm this bug with latest CVS, because it won't build, but this has been valid for apachephp4.dll for about two weeks. This issue can be stripped down to: it seems that with register_globals off, variables registered in a session become members of $HTTP_SESSION_VARS on the NEXT request, and when unregistered, get re-registered on the next request. The latter looks like an outstanding bug. The (lack of) presence of the error_reporting() calls in the beginning of all the files has no effect on the issue. Also, notice that when register_globals is on, session_is_registered() returns true, the global variable has it's value and is subsequently recreated on the next request, however, on the request where the session is started, $HTTP_SESSION_VARS is empty. With register_globals off, it already contains the variable when I traverse the array. (with the following bump: the increment call in the following block: $count = 0 ; session_register( 'count' ) ; $HTTP_SESSION_VARS['count']++ ; results in "undefined index" warning...) Seems like session support should be tagged 'experimental' on win32 Apache... Which is a pitty, as this httpd represents the shortest and most straightforward way from win32 dev machines to most unix servers... register_globals on ======================================================= test1.php ======================================================= error_reporting( E_ALL ) ; session_start() ; $count = 0 ; session_register( 'count' ) ; $count++ ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $count ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="/test2.php">test2.php</a>' ======================================================= relevant output: ======================================================= yes 1 ======================================================= test2.php ======================================================= error_reporting( E_ALL ) ; session_start() ; session_unregister( 'count' ) ; $count++ ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $count ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="/test3.php">test3.php</a>' ; ======================================================= relevant output: ======================================================= no 2 count : 1 test3.php ======================================================= error_reporting( E_ALL ) ; session_start() ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $count ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="test1.php">test1.php</a>' ; ======================================================= relevant output: ======================================================= no Warning: Undefined variable: count ... register_globals off ======================================================= test1.php ======================================================= error_reporting( E_ALL ) ; session_start() ; $count = 0 ; session_register( 'count' ) ; $HTTP_SESSION_VARS['count']++ ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $HTTP_SESSION_VARS['count'] ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="/test2.php">test2.php</a>' ======================================================= relevant output: ======================================================= Warning: Undefined index: count ... yes 1 count : 1 ======================================================= test2.php ======================================================= error_reporting( E_ALL ) ; session_start() ; session_unregister( 'count' ) ; $HTTP_SESSION_VARS['count']++ ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $HTTP_SESSION_VARS['count'] ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="/test3.php">test3.php</a>' ; ======================================================= relevant output: ======================================================= no 2 count : 2 test3.php ======================================================= error_reporting( E_ALL ) ; session_start() ; echo session_is_registered('count') ? 'yes' : 'no' ; echo $HTTP_SESSION_VARS['count'] ; foreach( $HTTP_SESSION_VARS as $k => $v ) { echo "$k : $v\n" ; } ; echo '<a href="test1.php">test1.php</a>' ; ======================================================= relevant output: ======================================================= yes 2 count : 2 -- Edit Bug report at: http://bugs.php.net/?id=8315&edit=1

« previous php.dev (#41802) next »