note 28568 added to function.session-is-registered
| From: | ryan at footboot dot net | Date: | Fri, 17 Jan 2003 03:11:58 +0000 |
| Subject: | note 28568 added to function.session-is-registered | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42248@lists.php.net to get a copy of this message | ||
isset($_SESSION[]) and session_is_registered() are not equivalent
---
$_SESSION['UID'] = 'temp';
print (int)session_is_registered('UID'); // false
print (int)isset($_SESSION['UID']); // true
---
Using session_register() there is an implicit call to session_start(), but it seems that using
$_SESSION variables without explicity calling session_start() will not initiate a session. So
it's possibled for this code to throw an error.
$_SESSION['var'] = 'blah';
if(isset($_SESSION['var'])) {
session_destroy();
}
Minorly dodgy, because there is no guaranteed way of avoiding it, given that they tell you not to
use session_is_registered() with $_SESSION. There should maybe be a session_is_started() function.
--
http://www.php.net/manual/en/function.session-is-registered.php
http://master.php.net/manage/user-notes.php?action=edit+28568
http://master.php.net/manage/user-notes.php?action=delete+28568
http://master.php.net/manage/user-notes.php?action=reject+28568