I am writing a anti-leeching download script, and my plan is to create a temporary file, which is named by session ID, then after the session expires, the file will be automatically deleted. Is it possible ? And can you give me some tips how to do that in PHP ?
Thanks so much for any reply
So we have one or more files available for download. Creating a temporary file for each download requests is not a good idea. Creating a
symlink()for each file instead is a much better idea. This will save loads of disk space and keep down the server load.Naming the symlink after the user’s session is a decent idea. A better idea is to generate a random symlink name & associate with the session, so the script can handle multiple downloads per session. You can use
session_set_save_handler()(link) and register a customreadfunction that checks for expired sessions and removes symlinks when the session has expired.