note 18160 added to function.session-unregister
| From: | JulienC at psychologie-fr dot com | Date: | Sat, 12 Jan 2002 14:34:20 +0000 |
| Subject: | note 18160 added to function.session-unregister | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-24743@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
--
http://www.php.net/manual/en/function.session-unregister.php
http://master.php.net/manage/user-notes.php?action=edit+18160
http://master.php.net/manage/user-notes.php?action=delete+18160
http://master.php.net/manage/user-notes.php?action=reject+18160