note 18160 deleted from function.session-unregister by philip
| From: | philip@php.net | Date: | Thu, 12 Dec 2002 03:06:01 +0000 |
| Subject: | note 18160 deleted from function.session-unregister by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40778@lists.php.net to get a copy of this message | ||
If you use sessions to manage people coming on your site that way:
-- People have a blank sessions when they connect.
-- When they enter their password, session keep firstname & lastname:
session_register('firstname'); $firstname='Julien';
session_register('lastname'); $lastname='Secret';
SO THE SESSION NOW CONTAIN: firstname|s:6:"Julien";lastname|s:6:"Secret";
-- There is a button to logout of the site, but the question is.. HOW TO BLANK HIS INFOS?
- session_unset: keep variable name and that's really not a nice way (there is no reason to
keep variables names).
THE SESSION WILL CONTAIN: !lastname|!firstname|
- session_destroy: will kill the session file and so remove all variables. But your user is
still online and then have to get a blank session. Using session_destroy(); then session_start();
give an error.
- session_unregister('firstname') works but you have to write all names of sessions
variables.
THE SESSION WILL CONTAIN: lastname|s:6:"Secret";
-- My solution is to use:
global $HTTP_SESSION_VARS;
foreach($HTTP_SESSION_VARS as $key => $value) { session_unregister($key); }
/jc