Page 1 of 1

Expire a hash in a database

Posted: Mon Oct 10, 2005 6:23 pm
by Luke
I am making a site where you pay for a packet of information, and once you sign up, it puts a hash of the following string:

$timestamp.$orderID.$customerip

I then store that information in the database, and when the customer wants to download the packet, they just have to follow a link with that hash appended to the url, I will have the page check that it is a valid hash, and then let them download the file. I want the hash that is in their database to expire after 24 hours or so... is there a way that you can change the hash stored in the database after 24 hours?

Also... how would I make it so that the file can't be downloaded by people other than the ones with valid hashes? Is there a way to protect files from being downloaded?

Posted: Mon Oct 10, 2005 6:52 pm
by josh
Store a timestamp with each record. To protect files place them in a non-web dir and read them out using php, and use header() to force a download.

Posted: Mon Oct 10, 2005 7:17 pm
by Luke
Alright... I got the time thing working... It just checks to see if 86400 seconds have elapsed. But the second part I don't know how to do.. what kind of features does php have that I can read the file with? fopen?

Posted: Mon Oct 10, 2005 7:22 pm
by feyd