...

View Full Version : Make a page that can only be visited once a day



blueskyler
08-28-2011, 04: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.

webdev1958
08-28-2011, 05: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.

FuquayDentist
08-28-2011, 05: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.

Jinxy
08-28-2011, 04:07 PM
Using cookies. Add this code to the top of your page:


<?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
setcookie( "visited", "", time()-60 );
?>

oracleguy
08-28-2011, 08: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.

embeebutterly
08-29-2011, 02: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.



***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
<body onload="$('#aLink').trigger('click');">
<a id="aLink" href="http://www.google.com" ></a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum