What are the best practices for managing and clearing the contents of the $_SESSION superglobal in PHP?

When managing and clearing the contents of the $_SESSION superglobal in PHP, it is important to unset individual session variables or destroy the entire session based on the requirements. To unset a specific session variable, you can use the unset() function. To destroy the entire session and delete all session data, you can use the session_destroy() function.

// Unset a specific session variable
unset($_SESSION['variable_name']);

// Destroy the entire session
session_destroy();