search for in the  
<session_unregistersession_write_close>
Last updated: Thu, 19 May 2005

session_unset

(PHP 4, PHP 5)

session_unset --  Free all session variables

Description

void session_unset ( void )

The session_unset() function frees all session variables currently registered.

Note: If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable, i.e. unset ($_SESSION['varname']);.

Caution

Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal.



User Contributed Notes
session_unset
guest at guest dot com
10-May-2005 11:21
Drew Bradford, this is not true.
session_destroy() DOES NOT unset any of the global variables associated with the session, or unset the session cookie.
more can be read here: http://br.php.net/manual/en/function.session-destroy.php
Drew Bradford - drew at drewbradford dot com
23-Jan-2005 04:07
You don't have to call session_destroy automatically performs the actions of the session_unset.

When you call session_unset, the session variable ($_SESSION) and corresponding session_id still exist.  So you're starting from scratch (no session variables), but you have the pre-existing session.

When you call session_destroy, it unsets all session variables, but also destroys the session itself, so PHP no longer tracks the corresponding session_id.
Jeroen
15-Jan-2005 03:42
note to Jason: I don't know the exact mechanics of it (since I'm quite new to sessions) but I think you need to use session_unset() BEFORE you can use session_destroy() at all.  I thought that session_unset() was for scripted variables, and session_destroy() just for anything saved on your side regarding the session.
21-Mar-2001 10:58
To further clarify the note above... this can be done via the session handling directives in your php.ini file... there are options to set garbage collection probability (via percent... i.e. 75 means it would run 3 out of every 4 page accesses), and the amount of time a session object can remain active before the garbage collection process sees it as garbage.
dmertens at zyprexia dot com
31-Jan-2001 11:11
The session files are automaticly deleted after the session-timeout is reached. So if the time-out is set to 20 minutes, the files will be deleted 20 minutes after the last access. Same for the cookie. Every time, an page is requested, the cookie-ttl is set to now + 20 minutes.

PHP is a very clean scripting engine, which leaves no garbage on your system!
diogo dot afonso at terravista dot pt
29-Aug-2000 12:09
The only thing needed to really destroy the session is :

session_unset();
session_destroy();
j a s o n p 0 1 9 at yahoo dot com
13-Jul-2000 03:26
session_unset() vs. session_destroy():
I would say that the difference is that session_destroy() destroys the session variables, both in the script and where the session data is stored on disk.  session_unset() is like doing a session_unregister() on all registered variables.  They can still be re-registered by calling session_register() whereas after session_destroy, they cannot.

<session_unregistersession_write_close>
 Last updated: Thu, 19 May 2005
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: The Server Pages
Last updated: Thu May 19 17:35:34 2005 CDT