newbie: the superglobal $_SESSION
| From: | bob | Date: | Sun, 10 Mar 2002 15:06:22 +0000 |
| Subject: | newbie: the superglobal $_SESSION | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87903@lists.php.net to get a copy of this message | ||
In mannual,it says:
creating new entries in the $_SESSION array will automatically
register them as session variables, as if you called
session_register().
If you are using $HTTP_SESSION_VARS/$_SESSION, do not use
session_register(), session_is_registered() and session_unregister()
unless you know internal of session module.
but ,
Example 1.
<?php
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}
else {
$_SESSION['count']++;
}
echo $count;
?>
I only get a warning :Warning: Undefined variable: count in
C:\WebShare\wwwroot\netk\5\test.php on line
whie in the following example:
<?php
session_register('count');
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}
else {
$_SESSION['count']++;
}
echo $count;
?>
it outputs 1(2,3......)
why?
thanks in advance.