Tag Archives: Practitioners

Unsetting Variables and Destroying the Session

When you are finished with a session variable, you can unset it.You can do this directly
by unsetting the appropriate element of the $_SESSION array, as in this example:
Note that the use of session_unregister() and session_unset() is no longer
required and is not recommended.These functions were used prior to the introduction
You should not try to unset the whole $_SESSION array because doing so will effectively
disable sessions.To unset all the session variables at once, use
$_SESSION = array();
When you are finished with a session, you should first unset all the variables and
then call  session_destroy();
to clean up the session ID.