How can the download process be improved to prevent multiple downloads when adjusting filters?

When adjusting filters on a download page, the download process can be improved by implementing a check to prevent multiple downloads of the same file. This can be achieved by setting a session variable upon successful download and checking this variable before allowing another download request.

<?php
session_start();

if(isset($_SESSION['downloaded_file'])) {
    echo "File has already been downloaded. Please try again later.";
} else {
    // Code to handle file download
    $_SESSION['downloaded_file'] = true;
}
?>