note 18974 added to ref.session
| From: | justin at quadmyre dot com | Date: | Tue, 12 Feb 2002 09:41:56 +0000 |
| Subject: | note 18974 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26501@lists.php.net to get a copy of this message | ||
The current documentation on the use of $_SESSION in favour of session_register() omits to mention
that registering your variables in the manner:
$_SESSION['cheese']='salmon';
does *NOT* implicitly start a session in the way that you might expect:
session_register($cheese);
to. This is not mentioned in the documentation, and the statement about not mixing use of $_SESSION
and older session functions leads you to believe it should be handled automagically. In fact you
must explicitly call session_start() before you assign/retrieve values to/from $_SESSION, eg:
session_start();
if (!isset($_SESSION['loggedIn']))
{
$_SESSION['loggedIn']=false;
}
elseif ($_SESSION['loggedIn'])
{
#Extra code if user logged in
}
--
http://www.php.net/manual/en/ref.session.php
http://master.php.net/manage/user-notes.php?action=edit+18974
http://master.php.net/manage/user-notes.php?action=delete+18974
http://master.php.net/manage/user-notes.php?action=reject+18974