Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make a page that can only be visited once a day

    I was just wondering if there was a way to make a page that can only be visited once a day somehow. Like using the IP or cookies.

  • #2
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Out of curiosity, why do you need to display a page only once per day? because whatever method you end up using I think it will be pretty easy for users to bypass it.

    Some users will have dynamic IP addresses. IP addresses can also be spoofed and cookies can be turned off in users' browsers and users could just go to another pc to view a page again on the same day.

    At best, if 1 visit per day is critical, you will be able to restrict access to a particular pc but you will have no way at all of knowing who is actually sitting at the keyboard.
    Last edited by webdev1958; 08-28-2011 at 05:25 AM.

  • #3
    New Coder
    Join Date
    Aug 2011
    Location
    Fuquay Varina NC
    Posts
    21
    Thanks
    1
    Thanked 2 Times in 2 Posts
    most users who are not advanced will be easily limited to once a day visits by your setting a cookie with one-day expiration. If it exists, then reroute them to another page.

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    86
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Using cookies. Add this code to the top of your page:
    PHP Code:
    <?php
    # if already visited, redirect to another page
    if ( $_COOKIE[visited] == "br549" )
    {
    header("location: http://your_domain.com/sorry.html");
    exit;
    }
    else
    {
    # Set Cookie & Expire Time
    $expire time()+60*60*24;
    setcookie"visited""br549"$expire);
    }
    ?>
    If you want to remove the cookie for testing purposes:

    PHP Code:
    <?php
    setcookie
    "visited"""time()-60 );
    ?>

  • #5
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Like webdev, I'm curious what you are trying to do that you need to limit it to once per day. There might be a better way to accomplish your goal.

    If you don't want to rely on cookies you could store the IPs in a database table with the timestamp. This has the disadvantage that if multiple visitors share the same IP, if one of them visits it, the other won't be able to. However they can't clear their cookies to bypass it.

    Cookies or storing the IP on the server both have downsides.
    OracleGuy

  • #6
    New Coder
    Join Date
    Jan 2011
    Posts
    82
    Thanks
    9
    Thanked 0 Times in 0 Posts
    I too am interested in this, my reason, not to Prevent or limit access, but to prevent the user having to see a particular "Message Page" more than once, but im looking for a slight variation.

    What i would like is a fancy box to load once on entry with a "How to Guide", users should have the option to "Close" or "Dont show me this again", the latter setting a cookie for life "or until cookie is removed. Any users blocking cookies do so at their own displeasure!


    I have some experience using fancy box but not with auto open or with cookie setting.



    Not sure if im supposed to do this, but i run a website that generates an income and would be pleased to donate to the coder who assists me.



    ***EDIT***

    I have now sorted the on load function of the fancybox, so i think ..... i just need the cookie to determine whether or not this bit is executed
    Code:
    <body onload="$('#aLink').trigger('click');">
    <a id="aLink" href="http://www.google.com" ></a>
    Last edited by embeebutterly; 08-29-2011 at 03:05 PM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •