What is the purpose of using unset() for session variables in PHP?
When using session variables in PHP, it is important to unset them when they are no longer needed to free up memory and prevent potential security risks. Unsetting session variables ensures that sensitive data stored in the session is properly cleared and not accessible after it is no longer needed.
// Unset a specific session variable
unset($_SESSION['variable_name']);
// Unset all session variables
session_unset();