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

To end a session in PHP, you can use the session_destroy() function. This function will destroy all data associated with the current session. It is important to call this function when you want to log a user out or end their session to ensure that no session data is left behind.

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

// Perform any necessary actions

session_destroy(); // End the session
?>