How can you optimize the deletion of session-related data in PHP to avoid performance issues?

To optimize the deletion of session-related data in PHP and avoid performance issues, you can use the session_unset() function to specifically unset the session variables you want to delete, instead of destroying the entire session with session_destroy(). This targeted approach helps in efficiently managing session data without affecting other session variables.

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