Forum Moderators: buckworks
I started selling ebooks and I'd need a way to send my buyers to a temporary location on the server where they can download files they purchased. That link would then expire in certain period of time.
Can anyone recommend a solution to this?
Thanks all!
After a successful purchase, store some form of unique but identifiable URL-ending:
insert into purchases (expire_date,download_link) values (date_add(now(), interval 24 hour),'john_t_doe@wherever.com');
(The date_add above is set for now plus 24 hours, it can be any valid datetime expression.)
You then provide the custmer with their download link, built from the database entry:
http://www.example.com/cgi-bin/somescript.cgi?d=john_t_doe@wherever.com
When somescript.cgi is called it looks up the entry in the database, if it exists, open the file from a secret location and print it to the browser. The actual location of the file is never revealed. If the entry doesn't exist, it's expired and display your favorite too bad, so sad message.
A cron job would come along every hour or so and delete entries where expire_date <= now().
You could be even more slick about it with some mod_rewrite and make the URL
http://www.example.com/john_t_doe@wherever.com
<Files *.pdf>
Order Deny, Allow
Deny from All
</Files>
piatkow-- I have server side processing and a database available but I'm not sure how to do it...
rocknbil-- your advice is too much for me. What would be the actual delivery script? I'm afraid I'd need more info to get started with this..
Morgenhund-- great advice for preventing leakage