1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Script That Blocks IP Address After A Set Period Of Time?

Discussion in 'JavaScript' started by gregdavidson, Jul 3, 2015.

  1. #1
    I need a script like this for my One Time Offer page. I already added a timer to that page which tells customers that the offer expires in 30 minutes. But they can still come back to that page because there's nothing there to block their IP addresses after the 30 minutes is up.
     
    Last edited: Jul 3, 2015
    gregdavidson, Jul 3, 2015 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Use cookies and check the time the cookie was set - more than 30 minutes ago? offer is withdrawn.

    Most users aren't smart enough to clear the cookies or change browsers. If someone is really determined they'll get past your best efforts so keep it simple and you'll stop most in their tracks.
     
    sarahk, Jul 4, 2015 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    Or store a quick overview of a combination of browser info, IP-address and other characteristics of the user in the database, and check to see if there's a match - more secure than just a cookie (you can of course store a cookie as well and check for that first, but if not found, you can also check the database).
     
    PoPSiCLe, Jul 4, 2015 IP
  4. Andy-Jones

    Andy-Jones Member

    Messages:
    134
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #4
    I think you will find such script on freehostedscripts or javascriptkit.
     
    Andy-Jones, Jul 4, 2015 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    And, yes, this shouldn't be done in javascript, as it's trivial to circumvent
     
    PoPSiCLe, Jul 4, 2015 IP
    deathshadow likes this.
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Yeah, scripttardery ain't gonna cut it. Scripting can be slapped aside with ridiculous ease, and many people browse with it disabled on purpose.

    Might I ask why you don't just store the IP, and MAYBE the UA string server-side? Of course, this is why MANY "one time offers" even if free track the user by validating a CC number or using IP + e-mail address verification.... but again that's ALL server-side and not JavaScript.
     
    deathshadow, Jul 4, 2015 IP
  7. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #7
    Do it in PHP instead. I saw this one on stackoverflow not too long ago while looking for something similar:

    <?php
    
    if(!isset($_COOKIE['visited'])){
    setcookie('visited',true, time()+3600*24);// Save a cookie for 1 day
    echo '<div class="your_div">Your awesome offer goes here...</div>';}
    
    ?>
    Code (markup):
     
    qwikad.com, Jul 23, 2015 IP
  8. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #8
    You can start the offer div/container with display=none css. Once the page is viewed, check for the cookie, if the cookie is not set change the display = inline and add the cookie.

    This will only show the offer on first load and you won't need server side scripting. However, server side scripting is more appropriate for such actions.
     
    ThePHPMaster, Jul 24, 2015 IP
  9. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #9
    Except that only using a cookie is trivial to get past - delete the cookie, and you can use the one-time offer again, if need be. Depending on the type of offer, this might not matter that much, of course, but still... depending on only a cookie isn't really smart.
     
    PoPSiCLe, Jul 24, 2015 IP