note 26510 added to function.session-register
| From: | felix at rack1 dot php dot net | Date: | Sat, 02 Nov 2002 00:04:07 +0000 |
| Subject: | note 26510 added to function.session-register | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38893@lists.php.net to get a copy of this message | ||
in contradiction to the above note that session_register() takes the current value of a variable and
does not watch for changes, this code sample works as intuitivly expected:
<?PHP
session_start();
echo $_SESSION['i'];
$i = 2;
session_register('i');
$i = 3;
echo '<a href="'.$PHP_SELF.'">click here</a>';
?>
this will result in $_SESSION['i] having the value of 3 after the first click.
this is not true for this sample:
<?PHP
session_start();
echo $_SESSION['i'];
$i = 2;
$_SESSION['i'] = $i;
$i = 3;
echo '<a href="'.$PHP_SELF.'">click here</a>';
?>
this will result in $_SESSION['i'] having the value 2 after the first click, but having
the value of 3 after the second click...
at least this is true for php4.2.3 on apache/win32
greetings
--
http://www.php.net/manual/en/function.session-register.php
http://master.php.net/manage/user-notes.php?action=edit+26510
http://master.php.net/manage/user-notes.php?action=delete+26510
http://master.php.net/manage/user-notes.php?action=reject+26510