deacon
12-13-2002, 12:26 PM
I submitted a long-winded request last week that got no replies so here is a less verbose version:
First page: need a set cookie script
Second page: need a read cookie + redirect (if the cookie exists).
I tried using an existing script that performs all of those functions on one page but have not been able to rework the script to separate the functions. If anyone wants to look at what I have, it's posted below. Thanks for any help
Existing script:
<script>
<!--
// page to go to if cookie exists
go_to = "otherpage.html";
// 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>
First page: need a set cookie script
Second page: need a read cookie + redirect (if the cookie exists).
I tried using an existing script that performs all of those functions on one page but have not been able to rework the script to separate the functions. If anyone wants to look at what I have, it's posted below. Thanks for any help
Existing script:
<script>
<!--
// page to go to if cookie exists
go_to = "otherpage.html";
// 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>