Home > Php > Sessions in PHP : Part 4 – Cleaning and destroying PHP session

Sessions in PHP : Part 4 – Cleaning and destroying PHP session

January 7th, 2010 Leave a comment Go to comments    

The unset() function is used to unset or free a session variable that has been set. A session can be completely destroyed by using the session_destroy() function.
Example code:

<?php
unset($_SESSION['views']);
?>

All the stored data of the session will be deleted on calling the session_destroy() function.

Example code:


Session_start();
session_destroy();
?>

Categories: Php Tags:
  1. No comments yet.
  1. No trackbacks yet.