Jump to content

Authenticating A Download Link


mostafatalebi

Recommended Posts

Hello

I am going to purchase a Download Host, and it does not support Database. I have to purchase a Regular Host next to it. The ordinary workflow is that I put the link of files (which have been upload in my Download Host) in my website. But how Can I authenticize my download links? so that a link is only valid for about 1 day and after that expires? Thanks

Link to comment
https://forums.phpfreaks.com/topic/271951-authenticating-a-download-link/
Share on other sites

*authenticate (sorry, but that was driving me insane)

 

This is a simple login system.  Only privileged users can download files.

 

1. user registers and pays to become 'paid user'

 

2. paid user gets flagged in the db as a 'paid user' with a simple column in the `users` table such as `paid` (default=0 not paid, 1 = paid), or create a privilege system, which is a little more work, but has greater ability to scale.  This can be a range of values: 0 = free user, 1 = registered user, 2 = paid user, 3 = god mode, etc.

 

3. build your download script to ensure the user is logged in:

 

// download.php
// quick pseudo code for logic
session_start();

if ($_SESSION['auth']) {
// user is logged in
// check to ensure user has privileges to download this file (query or $_SESSION variable housing that value)

// insert download code if user above check has passed
}
else {
// user is not logged in
// quit and redirect to appropriate page
header('Location: /payment_page.php');
exit(0);
}

 

Just the jist of it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.