Jump to content

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

Edited by Pikachu2000
Title corrected . . .
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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.