Removing session data
Removing a specific value from a session is as simple as using the function unset(), just as you would for any other variable. It is important that you should unset only specific elements of the $_SESSION array, not the $_SESSION array itself, because that would leave you without any way to manipulate the session data at all.
To extend the previous script to remove data, use this:
<?php
$_SESSION['foo'] = 'bar';
print $_SESSION['foo'];
unset($_SESSION['foo']);
?>
Next chapter: Ending a session >>
Previous chapter: Reading session data
Jump to:
Home: Table of Contents



Copyright 2012 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK