I am required to create a small website that people access through a html login/password form where a session begins. I have completed this however I need to log when a user clicks a link and downloads a file.
I need to record which user has clicked to downloaded the file.
All I have at the moment is a link to a download.php as follows
link
<a href="download.php">download</a>
file
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="somefile.pdf"');
readfile('somefile.pdf');
how would I go about logging who has actually downloaded a file?
It would be very trivial to record the session login details at the top of the download.php file. It’s not necessary to redirect via another intermediary file.
If you want to stop people directly linking to download.php you should put some security check at the start of download.php.