What is the best practice for completely deleting a session in PHP, including the session ID and session variables?

To completely delete a session in PHP, including the session ID and session variables, you should first unset all session variables, destroy the session data, and then regenerate a new session ID. This ensures that all session data is removed and a new session is started with a clean slate.

<?php
session_start();

// Unset all session variables
$_SESSION = array();

// Destroy the session data
session_destroy();

// Regenerate a new session ID
session_start();
session_regenerate_id();

echo "Session has been completely deleted.";
?>