ID:               16700
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: All (tested on win32 and linux)
 PHP Version:      4.1.2
 New Comment:

I've fixed the examples. 4.2.0 will be released really soon now so
there's (IMHO) no need to update the docs for that.


Previous Comments:
------------------------------------------------------------------------

[2002-04-19 12:39:32] [EMAIL PROTECTED]

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 this bug report at http://bugs.php.net/?id=16700&edit=1

Reply via email to