RE: [PHP] Need Help with $_SESSION.
| From: | Johnson, Kirk | Date: | Wed, 03 Jul 2002 17:53:50 +0000 |
| Subject: | RE: [PHP] Need Help with $_SESSION. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105253@lists.php.net to get a copy of this message | ||
> Now, I still can not understand why the 2nd page show the $_SESSION as
> blank. It is suppose to contain datas. The php.net stated
> that $_SESSION
> is global. Any comments?
register_globals on
-------------------
Page 1
<?
session_start();
$foo = 'bar';
session_register('foo');
$foo = 'someNewValue';
?>
Page 2:
<?
session_start();
echo $foo;
$foo = 'aDifferentValue';
?>
register_globals off
--------------------
Page 1:
<?
session_start();
$_SESSION['foo'] = 'bar';
$_SESSION['foo'] = 'someNewValue';
?>
Page 2:
<?
session_start();
echo {$_SESSION['foo']}; // several syntaxes to do this
$_SESSION['foo'] = 'aDifferentValue';
?>
Kirk