What is the difference between session_unset() and session_destroy() in PHP?
session_destroy();
is deleting the whole session.
session_unset();
deletes only the variables from session - session still exists. Only data is truncated.
session_unset
just clears the $_SESSION
variable. It’s equivalent to doing:
$_SESSION = array();
So this does only affect the local $_SESSION
variable instance but not the session data in the session storage.
In contrast to that, session_destroy
destroys the session data that is stored in the session storage (e.g. the session file in the file system).
Everything else remains unchanged.