How does session_destroy() affect the current session in a PHP script?

session_destroy() function in PHP deletes all data associated with the current session, effectively ending the session. This means that all session variables and data will be deleted, and the user will be logged out of the current session. It is commonly used to log users out of a website or reset the session data.

<?php
session_start();

// Perform any necessary tasks

// Destroy the session
session_destroy();
?>