Are there best practices for preventing session variables from persisting across page reloads in PHP?

When using session variables in PHP, they are typically stored in a server-side file or database and are accessible across multiple pages within the same session. However, if you want to prevent session variables from persisting across page reloads, you can unset or destroy the session variables when they are no longer needed.

// Start the session
session_start();

// Set session variables
$_SESSION['username'] = 'john_doe';

// Unset session variables to prevent them from persisting across page reloads
unset($_SESSION['username']);

// Destroy the session
session_destroy();