1session_destroy(); // To delete whole session
2// OR
3unset($_SESSION['myVar']); // To delete a session var
1
2<?php
3// Initialize the session.
4// If you are using session_name("something"), don't forget it now!
5session_start();
6
7// Unset all of the session variables.
8$_SESSION = array();
9
10// If it's desired to kill the session, also delete the session cookie.
11// Note: This will destroy the session, and not just the session data!
12if (ini_get("session.use_cookies")) {
13 $params = session_get_cookie_params();
14 setcookie(session_name(), '', time() - 42000,
15 $params["path"], $params["domain"],
16 $params["secure"], $params["httponly"]
17 );
18}
19
20// Finally, destroy the session.
21session_destroy();
22?>
23
24