10.6 Deleting All the Session Variables


10.6 Deleting All the Session Variables

You want to clear all the variables in the current session.

Technique

Use the session_destroy() function to wipe out the session:

 <?php session_start(); session_register("foo"); session_register("foobar"); session_register("foobarina"); $foo        = array ("banana", "apple", "orange", "mango"); $foobar     = "fruits"; $foobarina  = "vegetables"; session_destroy(); print $foobar; ?> 

Comments

The session_destroy() function will delete the session data from the session store. Note that it will not delete session variables' contents. For that, you need to use the session_unset() function to go through all session variables and remove them from the symbol table.



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