10.5 Unregistering a Variable in a Session


You need to remove a session variable or unregister it before script execution ends.

Technique

Use PHP's session_unregister() function instead of unset() to remove the variable from the session:

 <?php session_register('somevar'); if (session_is_registered('somevar')) {     session_unregister('somevar')         or die('Could not unregister somevar'); } ?> 

Comments

The session_unregister() function removes the specified variable from the session registry, so that when the session is saved, it will not contain the newly unregistered variable. This function does not delete the variable's contents, however.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net