Checking if user is currently downloading a file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Smudly
Forum Commoner
Posts: 71
Joined: Wed Jun 09, 2010 10:09 pm

Checking if user is currently downloading a file

Post by Smudly »

Hi,

I'm trying to figure out the best way to determine if a user is currently downloading a file from my website.
The way my site works, is the user waits 30 seconds and views an ad. After the timer is up the download becomes available.
I heard that I could probably use a timestamp or something of the sort. I've read up on it but not sure how I could go about this.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Checking if user is currently downloading a file

Post by requinix »

Create some sort of download ID in your database. It relates a user with a download. It also knows when the download was requested, whether it's in the show-an-ad state or the doing-the-download state, and the time that the download was/will be available (ie, requested time + 30 seconds).

Whatever you use to do the download looks up the ID and determines whether it should send the file or not. If not, show a warning or redirect to the ad or whatever.
Post Reply