What potential syntax errors can occur when trying to unset variables in a PHP session?

When unsetting variables in a PHP session, potential syntax errors can occur if the variable being unset is not properly referenced within the session array. To avoid this issue, make sure to use the correct syntax by referencing the variable within the session array using the session superglobal ($_SESSION) followed by the variable name.

// Unset a variable in a PHP session
session_start();

// Check if the variable exists before unsetting
if(isset($_SESSION['variable_name'])) {
    unset($_SESSION['variable_name']);
}