Forums
This topic is locked
Erase cookies on page load?
09 Oct 2007 09:31:06 Seng Seng posted:
Hey guys,I've created 2 pages, "welcome.asp" and "bye.asp".
When the user loads welcome.asp, a cookie is stored (which I managed to do it already); but once the user loads bye.asp, the cookie is deleted/erased... how do I do this?
Here's the code for the cookie in 'welcome.asp':
--------------------------------------------------------------
<script>
<!--
// page to go to if cookie exists
go_to = "bye.asp";
// number of days cookie lives for
num_days = 1;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*30*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>
--------------------------------------------------------------------------------------------------