What are the potential pitfalls of using unset($_SESSION) to destroy a session in PHP?

Using unset($_SESSION) to destroy a session in PHP can lead to unintended consequences, such as only destroying the session variables but not the session itself. This can leave the session active and potentially vulnerable to session hijacking. To properly destroy a session, you should use session_destroy() function instead.

// Properly destroy a session
session_start();
$_SESSION = array();
session_destroy();