Good to unset $_SESSIon befoer destroying it?

In many examples I have seen, when a user logs out, each thing in a session is unset (ex. unset($_SESSION[‘email’]))and then the session is destroyed (ex. session_destroy()).

What is the purpose of unsetting a session’s elements if you are just going to destroy the session itself anyway?

Because the session is still accessible on the same page load.

For example:


session_start();

$_SESSION['blah'] = 'adsf';

session_destroy();

echo $_SESSION['blah'];

I just found that out while running tests. Thanks.