View Full Version : Make a page that can only be visited once a day
08-28-2011, 05:59 AM
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.
08-28-2011, 06:05 AM
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.
08-28-2011, 06:22 AM
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.
08-28-2011, 05:07 PM
Using cookies. Add this code to the top of your page:
# if already visited, redirect to another page
if ( $_COOKIE[visited] == "br549" )
# Set Cookie & Expire Time
$expire = time()+60*60*24;
setcookie( "visited", "br549", $expire);
If you want to remove the cookie for testing purposes:
setcookie( "visited", "", time()-60 );
08-28-2011, 09:48 PM
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.
08-29-2011, 03:21 PM
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.
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
<a id="aLink" href="http://www.google.com" ></a>
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.