What is the recommended method for implementing a logout script in PHP without using MySQL?

When implementing a logout script in PHP without using MySQL, you can simply unset the session variables that were set during the login process. This effectively logs the user out by removing their session data.

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

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

// Destroy the session
session_destroy();

// Redirect to the login page
header("Location: login.php");
exit;
?>