How to limit file downloads

Discussion in 'PHP' started by BLaZeR, Jan 26, 2007.

  1. #1
    I was wondering if you could make it that someone can only download 2 files at a time ? If so could somebody please send me a script or program?
     
    BLaZeR, Jan 26, 2007 IP
  2. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use cookies:
    if ($_COOKIES['downloads'] > 1) {
      echo "please download no more than 2 files at once";
    } else {
      setcookie("downloads", $_COOKIE['downloads'] + 1);
    }
    PHP:
    This is just a start, you might want to check that the user accepts cookies, validate input, etc. etc.
     
    picouli, Jan 26, 2007 IP
  3. BLaZeR

    BLaZeR Peon

    Messages:
    1,567
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How do I do that? I'm still new to this whole concept. Like how do i add it in cpanel or do I insert it to a html or php document.
     
    BLaZeR, Jan 26, 2007 IP
  4. picouli

    picouli Peon

    Messages:
    760
    Likes Received:
    89
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You should add it at the top of the download script... I think you should ask the people who wrote it - or you start learning PHP, starting from here: http://www.php.net ;)
     
    picouli, Jan 26, 2007 IP
  5. BLaZeR

    BLaZeR Peon

    Messages:
    1,567
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do i have to set the cookies first or do i just add the code you gave me to the top of the php file?
     
    BLaZeR, Jan 26, 2007 IP