...

View Full Version : Adjusting Cookie



javanewbie7
12-15-2011, 05:05 PM
Hey all,

I have set up a cookie that redirects the visitor if they have visited the page before. However, I'd like to make some adjustments to it to where if they have cookies turned off, it automatically redirects them to a page that requests them to turn on cookies. Any ideas?



<script>
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;
}
}

var go_to = "/index.php?module=article&id=310";

readCookie("seenit");
</script>

javanewbie7
12-15-2011, 05:50 PM
nevermind. I figured it out. Looks like I'm finally starting to understand js



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum