From:             [EMAIL PROTECTED]
Operating system: All (tested on win32 and linux)
PHP version:      4.1.2
PHP Bug Type:     Documentation problem
Bug description:  Code samples relating to use of sessions is broken, and other issues.

Please don't disregard this, it is not just a product of the 4.1.2 win32
$_SESSION bug.

The examples 1,2 and 3 regarding the use of $_SESSION and
$HTTP_SESSION_VARS all omit to mention that you still have to call
session_start() before you can use any of them. The caution regarding
mixing use of these variables and the session functions compounds this.

<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
    $_SESSION['count'] = 0;
} else {
    $_SESSION['count']++;
}
?>

The example simply does not work under any version of PHP, and is
extremely confusing for newbies, and an intense waste of time for those of
us who found out about the win32 $_SESSION bug the hard way.

They should read:

Example 1:
<?php
session_start();
if (isset($HTTP_SESSION_VARS['count'])) {
   $HTTP_SESSION_VARS['count']++;
}
else {
   $HTTP_SESSION_VARS['count'] = 0;
}
?>

Example 2:
<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
session_start();
if (!isset($_SESSION['count'])) {
    $_SESSION['count'] = 0;
} else {
    $_SESSION['count']++;
}
?>

Example 3:
<?php
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
session_start();
unset($_SESSION['count']);
?>

I would also recommend adding the following notes:

Note: When using $_SESSION or $HTTP_SESSION_VARS to register / get session
variables, you must call session_start() to start the session, otherwise
no session information will be saved.

Note: In the **Win32 only** build of PHP 4.1.2, support for $_SESSION and
$HTTP_SESSION_VARS is broken, and no data is stored in the session file.
Session_register() etc still works, but since the use of register_globals
/ session_register() is depracated and many people have now disabled
register_globals anyhow, the workaround currently is to downgrade to PHP
4.1.1 / 4.1.0, or wait for the next release version. **This bug does not
affect any linux builds of PHP**.

I know that seccond note is not the sort of thing you probably want to
publicise, but having read the current discussions on this bug the
official line seems to be that the bug is fixed in the upcoming 4.2.0 but
4.1.2 is not going to be re-released. However, most people developing on
win32 at the moment, and many people in the future are going to come up
against the problem and be stumped.

There should also be a note on the download page warning people who are
currently blindly being advised to upgrade to 4.1.2 that this bug is
present in the win32 build, and 4.1.1 offered as an alternative on the
win32 platform.
-- 
Edit bug report at http://bugs.php.net/?id=16700&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16700&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16700&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16700&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16700&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16700&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16700&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16700&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16700&r=submittedtwice

Reply via email to