What potential issues can arise when using session_destroy() in a form in PHP?

Potential issues that can arise when using session_destroy() in a form in PHP include the destruction of all session data, including the session ID, which can lead to unexpected behavior or errors in the application. To solve this issue, it is recommended to unset the specific session variables you want to destroy instead of using session_destroy().

<?php
session_start();

// Unset specific session variables
unset($_SESSION['variable1']);
unset($_SESSION['variable2']);

// Redirect to another page or display a success message
header("Location: another_page.php");
exit;
?>