How can one properly unset or delete session variables in PHP?

To unset or delete session variables in PHP, you can use the unset() function to remove a specific session variable or session_destroy() function to remove all session variables. It's important to note that session_destroy() will also delete the session cookie, effectively ending the session.

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

// Delete all session variables and destroy the session
session_destroy();