What is the difference between using session_destroy() and unset($_SESSION('name')) in PHP?

The main difference between using session_destroy() and unset($_SESSION['name']) in PHP is that session_destroy() will completely destroy all session data, while unset($_SESSION['name']) will only unset a specific session variable. If you want to destroy the entire session, including all session variables, you should use session_destroy(). If you only want to unset a specific session variable, you should use unset($_SESSION['name']).

// Using session_destroy() to completely destroy the session
session_start();
session_destroy();

// Using unset($_SESSION['name']) to unset a specific session variable
session_start();
unset($_SESSION['name']);