PHP/Cookie Session/session destroy
Destroying a session
<?php
session_start( );
$_SESSION["username"] = "Michele";
session_destroy( );
echo "At this point we can still see the value of username as ";
echo $_SESSION["username"]."<br />";
unset ($_SESSION["username");
if (is_null($_SESSION["username"])) {
echo "Now the value of username is (blank)";
}
?>
Ending a Session
<?
session_start( );
$_SESSION = array( );
session_destroy( );
?>
function session_destroy() ends all persistent data corresponding to the current user session.
Its syntax is: boolean session_destroy()
<?
session_start();
// do some session stuff
session_destroy();
?>