What is the difference between using unset("variable") and unset($_SESSION['variable']) to delete session variables in PHP?

Using unset("variable") will not unset a session variable, as it only works for regular variables. To delete a session variable in PHP, you need to use unset($_SESSION['variable']). This will properly unset the session variable and free up the memory it was using.

<?php
// Initialize the session
session_start();

// Set session variable
$_SESSION['variable'] = "value";

// Unset session variable
unset($_SESSION['variable']);
?>