Hello, I'm not sure if this is a php issue, but I would like to set up a page that will allow for a 1 time download (say give someone 1-2 hours to download a given video file after purchase).

I'm thinking it would need to be a code that would randomly generate when asked, but expire in 60 minutes.

I would like the individual to pay for a video on our page and then be able to download the mpg file for viewing. I would like this to be secured so that the link can't be shared.. I figured an expiration code would do this the best without a login page?

Can anyone point me in the right direction? I'm not even sure what kind of tutorial or information I should be looking for to do this. Is there an easier way?

Thanks in advance,
Steve

Member Avatar for diafol

IMO
Have a database table with orders:

orders
order_id (int/PK)
user_id (int/FK)
video_id (intFK)
ordertime (unix timestamp)

Check that the ordertime is within time() <= ordertime + 7200 for 2hrs or time() <= ordertime + 3600 for 1 hr

OR the alternative ordertime >= time() - 7200 etc

Just ensure that you have a consistent timezone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.