ID: 22068
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Documentation problem
Operating System: Windows XP
PHP Version: 4.3.0
New Comment:
Bogus?
PAGE 1 (test_index.php):
===========================================================
<? include ('test_session.inc');
session_start ();
?>
<HTML><HEAD><TITLE>Test session</TITLE></HEAD>
<BODY TEXT="#000000" LINK="#FFCC00" ALINK="#33FF00" VLINK="#FFCC00"
bgcolor="#FFFFFF">
<br>
<u><i>test_index.php</i></u><br>
<br>
<? sessRESTORE();
$_SESSION['direkt'] = 'Wert';
sessVAR( 'test', '1234' );
print( "<i>session_id() = '".session_id()."'</i><br>\r\n" );
print( "<i>\$_SESSION['test'] =
'".((isset($_SESSION['test']))?$_SESSION['test']:'not
set')."'</i><br>\r\n" );
print( "<i>\$test = '".((isset($test))?$test:'not
set')."'</i><br>\r\n" );
print( "<i>\$_SESSION['direkt'] =
'".((isset($_SESSION['direkt']))?$_SESSION['direkt']:'not
set')."'</i><br>\r\n" );
print( "<i>\$direkt = '".((isset($direkt))?$direkt:'not
set')."'</i><br>\r\n" );
?>
<br>
<a href="test_start.php?<?=SID?>"><b>next</b></a><br>
</BODY></HTML>
-----------------------------------------------------------
PAGE 2 (test_start.php):
===========================================================
<? include ('test_session.inc');
session_start ();
?>
<html><head><title>Test session</title></HEAD>
<BODY TEXT="#000000" LINK="#FFCC00" ALINK="#33FF00" VLINK="#FFCC00"
bgcolor="#FFFFFF">
<br>
<i><u>test_start.php</u></i><br>
<br>
<? sessRESTORE();
print( "<i>session_id() = '".session_id()."'</i><br>\r\n" );
print( "<i>\$_SESSION['test'] =
'".((isset($_SESSION['test']))?$_SESSION['test']:'not
set')."'</i><br>\r\n" );
print( "<i>\$test = '".((isset($test))?$test:'not
set')."'</i><br>\r\n" );
print( "<i>\$_SESSION['direkt'] =
'".((isset($_SESSION['direkt']))?$_SESSION['direkt']:'not
set')."'</i><br>\r\n" );
print( "<i>\$direkt = '".((isset($direkt))?$direkt:'not
set')."'</i><br>\r\n" );
?>
<br>
<a href="test_index.php?<?=SID?>"><b>back</b></a>
</body></html>
-----------------------------------------------------------
FUNCTIONS (test_session.inc):
===========================================================
<?
function sessVAR ($name, $wert) {
global $_SESSION;
$_SESSION[$name] = $wert;
eval('global $'.$name.'; $'.$name.'=$_SESSION[\''.$name.'\'];');
}
function sessRESTORE () {
global $_SESSION;
while ( list ($key, $value) = each ($_SESSION) ) {
eval( 'global $'.$key.'; $'.$key.'=$_SESSION[\''.$key.'\'];' );
print( 'sessRESTORE $'.$key."<br>\r\n" );
}
}
?>
-----------------------------------------------------------
First Test - PAGE 1 displays:
=============================
test_index.php
session_id() = 'a8422f455c75aec5a3654c2894f7b4f2'
$_SESSION['test'] = '1234'
$test = '1234'
$_SESSION['direkt'] = 'Wert'
$direkt = 'not set'
next
First Test - PAGE 2 displays:
=============================
test_start.php
session_id() = 'a8422f455c75aec5a3654c2894f7b4f2'
$_SESSION['test'] = 'not set'
$test = 'not set'
$_SESSION['direkt'] = 'not set'
$direkt = 'not set'
back
First Test - continued:
=======================
If I goon switching between these two pages, I get the same results for
each page as shown above.
For the following second test the statements 'global $_SESSION;' within
the functions of 'test_session.inc' are deactivated!
Second Test - PAGE 1 displays:
==============================
test_index.php
session_id() = '91f0a63c90e8a567610a3a9ec5195202'
$_SESSION['test'] = '1234'
$test = '1234'
$_SESSION['direkt'] = 'Wert'
$direkt = 'not set'
next
Second Test - PAGE 2 displays:
==============================
test_start.php
sessRESTORE $direkt
sessRESTORE $test
session_id() = '91f0a63c90e8a567610a3a9ec5195202'
$_SESSION['test'] = '1234'
$test = '1234'
$_SESSION['direkt'] = 'Wert'
$direkt = 'Wert'
back
Second Test - continued:
========================
If I goon switching between these two pages, I get the correct results
as shown in Page 2 Display!
Previous Comments:
------------------------------------------------------------------------
[2003-02-05 14:31:37] [EMAIL PROTECTED]
The documentation is clear enough to me (us).
Using the global keyword on any $_* shouldn't create a new variable. If
it does, this is not a documentation bug. I verified with PHP4.3 and
5.0 (ZE2), it doesn't.
Not a bug -> Bogus.
Feel free to post a new bug if you feel we are wrong.
------------------------------------------------------------------------
[2003-02-05 05:24:57] [EMAIL PROTECTED]
Documentation problem
------------------------------------------------------------------------
[2003-02-05 05:23:57] [EMAIL PROTECTED]
The manual says at topic XCIII. SESSION HANDLING FUNCTIONS under
headline EXAMPLES within the NOTE, 'you do not need to use the global
keyword for $_SESSION'.
In fact you 'may not use the global keyword' when accessing $_SESSION
from within a function, otherwise a different global variable seems to
be created/accessed (PHP 4.3.0, WinXP)!
Maybe it is no bug, but I miss any sematically sense.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22068&edit=1
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php