session_unregister

(PHP 4, PHP 5)

session_unregister --  Unregister a global variable from the current session

Description

bool session_unregister ( string name )

session_unregister() unregisters the global variable named name from the current session.

This function returns TRUE when the variable is successfully unregistered from the session.

Замечание: If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable. Do not unset() $_SESSION itself as this will disable the special function of the $_SESSION superglobal.

Предостережение

This function does not unset the corresponding global variable for name, it only prevents the variable from being saved as part of the session. You must call unset() to remove the corresponding global variable.

Предостережение

If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().



session_unregister
Martin Pilka
18-May-2005 01:19
Same here. Unless I use session_unregister('varname') after unset(), varname is unset in current request, but set again in following request.

I use $_SESSION[] array, register_globals is off. session_unregister() is needed in spite what documentation says. PHP 4.1.2, Debian, package "php4 4.1.2-7.0.1".
dylan82 AT xs4all DOT nl
09-Dec-2004 01:13
If globals is on, you'll have to unset the $_SESSION[varname] as well as the $varname.

Like:

unset($_SESSION[varname]);
unset($varname);
jsmith at uncommoner dot com
26-Nov-2004 10:55
as a side note you must have session_start() set inorder to actually unregister the session varibles.
Somatik
10-Aug-2004 12:30
In reply to the above comment. If you forget the session_start(); you might have that problem. unset($_SESSION("varname")); works fine here.
jop at yes2web dot nl
28-Jun-2004 05:33
It took me some time to figure this out:
If you have register globals off, you probably use $_SESSION to acces you session vars. If you want clear a sessionvar inside the current script, but also in next pages, do this as follows:

session_unregister('varname');

Otherwise varname will keep returning either inside the script, or on the next pages.

unset($_SESSION['varname']) will only unset the session var on the current page.

<session_startsession_unset>
 Last updated: Tue, 15 Nov 2005