What is the purpose of the code snippet provided for logging out in PHP?
The purpose of the code snippet provided for logging out in PHP is to destroy the session data and unset the session cookie, effectively logging the user out of the current session. This helps to ensure the security of the user's account by removing any active session data.
session_start();
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();