PHP Destroying a Session
Posted by tutor | Posted in PHP Tutorial | Posted on 08-08-2010-05-2008
0
PHP isset() Function
When we create a variable and store it in a session, it is with the intention to use it in the future. But to use a session variable it should first be created and set. So you must first check for its existence.
Here we use PHP’s isset function. isset is a function that takes any variable you want to use and checks to see whether it has been assigned some value or not.
Destroying a Session
If you wish to delete some session data, you can use the following two functions:
- unset() function
- session_destroy() function
The unset() function is used to free the specified session variable:
unset($_SESSION['views']);
?>
You can also completely destroy the session by calling the session_destroy() function:
session_destroy();
?>
session_destroy() will reset your session and you will lose all your stored session data.
