62
<script>
<!--
// page to go to if cookie exists
go_to = "http:// www. YOURDOMAIN .com";
// number of days cookie lives for
num_days = 60;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*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>
Changing days to hours
If you would like the cookie to expire immediately or in a matter of hours or minutes, you can make the following modifications :
To have the cookie expire immediately, set the num_days variable to a negative number. Eg.
num_days = -1;
To have the cookie expire in a matter of hours, remove the *24 from the ged (Get Expiration Date) function. The num_days = 5; variable will now be the number of hours. For your information, the rest of the figures mean, times 60 seconds, times 60 minutes, times 1000 milliseconds.
***make sure to replace and close up the yourdomain.com .. it was expanded so it would show in the code window...