What is the function used to destroy a session in PHP?

To destroy a session in PHP, you can use the session_destroy() function. This function will unset all session variables and destroy the session data. It is commonly used when a user logs out of a website or when you want to clear all session data.

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

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

// Destroy the session
session_destroy();
?>