debstah
06-06-2006, 01:54 PM
Hi - I hope someone can help!
I've installed a cookie script on a webpage that redirects the visitor to certain page on my website, if the cookie is detected. It's set to expire after 24hours (although I'm not sure if I used the right code), and I tested it, and it works fine.
However, if I change the date on my computer to tomorrow, it "tricks" the cookie into being ignored. Is there a way to stop this from happening? I only want visitors to access the cookie page once in 24 hours - the page contains a poll and I only want them to vote once in a 24-hour period. I don't want anybody cheating by tricking the cookie, over and over again....
Here is the script:
<script>
// page to go to if cookie exists
go_to = "http://www.buzzthebiz.com/htm/Forms/nobuzz.htm";
// number of days cookie lives for
num_days = 24;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
// -->
</script>
Thanks in advance for your help!
Deb
I've installed a cookie script on a webpage that redirects the visitor to certain page on my website, if the cookie is detected. It's set to expire after 24hours (although I'm not sure if I used the right code), and I tested it, and it works fine.
However, if I change the date on my computer to tomorrow, it "tricks" the cookie into being ignored. Is there a way to stop this from happening? I only want visitors to access the cookie page once in 24 hours - the page contains a poll and I only want them to vote once in a 24-hour period. I don't want anybody cheating by tricking the cookie, over and over again....
Here is the script:
<script>
// page to go to if cookie exists
go_to = "http://www.buzzthebiz.com/htm/Forms/nobuzz.htm";
// number of days cookie lives for
num_days = 24;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
// -->
</script>
Thanks in advance for your help!
Deb
