views:

22

answers:

1

I am using PHP and MySQL and I want to sell my Digital EBooks on line. I want to give a Download Link to my clients who buys my EBook but I want to secure my digital download links to work for only 3 times and the Download Link should be deleted automatically after 24 hours or after 3 tries to downloads.

How can I fulfill this requirement.

Since I don't want to buy any Digital Download Service. I want to create my own.

+1  A: 

At the point that they make a purchase, generate a unique identifier and incorporate this in the URL.

Then when that URL is visited, lookup the code, see when it was created and how many times its been used, and either send the content or an error, accordingly.

To expand on this:

User visits your site, buys somecontent.txt, and pays their money. You then generate a random string and give them a link that looks like:

www.yoursite.com/download?content=somecontent.txt&authKey=fdkjhwsiufhwaoeuhfq

where the string at the end is the one you generated, and stored in the DB.

At some time later, the buyer uses the link. Your code then goes 'Aha! - that code was created as a result of the user Fred buying some content. His payment was received, and its the first time its been downloaded, so I'll send him the file, and increment the counter that records how many times that specific user has used that specific code.

Eventually, due to either a time expiry, or having been used too many times, your code will instead turn around and say 'Sorry Fred, that link is too old/has been used too many times'...at which point they can re-buy the content, for example, at which point you can generate a new code.

Visage
Would you please clear the solution. I can't understand properly.
Kuldeep Chand