Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unset() a session variable inside of a function

Status
Not open for further replies.

rudenborg

Programmer
May 18, 2004
19
US
Hi-

I have what should be a simple question. I've searched through this forum and php.net and google and haven't found a satisfactory answer to it though.

What is the sure way to completely destroy (globaly) a session variable inside of a function.

as an example:

$_SESSION['blah'] = 'blah';

function blah()
{
// i need to delete $_SESSION['blah']
// what code should I use here???
}

// now any refference to $_SESSION['blah'] should return an error saying it doesn't exist.


Thanks!

Jonathan
 
What about:
Code:
unset ($_SESSION['blah']);
 
$_SESSION is a superglobal array, which means that it appears in every variable scope. You don't have to do anything special to $_SESSION (or $_POST, $_GET, etc.) to be able to manipulate it.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top