Hi All,
I am having trouble getting this javascript to set a cookie on any browser. Below are the two scripts I am using and if anyone can save me from this week of frustration by telling me what I am doing wrong, I would greatly appreciate it.
This is the readCookie script that properly redirects after not finding the cookie.
<script>
<!--
// page to go to if cookie does not exist
go_to = "http://www.mywebsite.com/index.html";
function readCookie(TheCookieName){
var start = document.cookie.indexOf(TheCookieName);
if (start == -1){
window.location = go_to;
}
else{
document.cookie = "access=no; expires=" + ged(num_days);
}
}
readCookie("access");
// -->
</script>
This is the setCookie script that is not working for me.
<script type="text/javascript">
<!--
// function setCookie('TheCookieName', 'MyValue', '3', '/', '.mywebsite.com', ")
{ document.cookie = name + "=" + escape(value) + "; ";
if(expires){expires = setExpiration(expires);
document.cookie += "expires=" + expires + "; ";
}
if(path){
document.cookie += "path=" + path + "; ";
}
if(domain){
document.cookie += "domain=" + domain + "; ";
}
if(secure){
document.cookie += "secure; ";
}
}
function setExpiration(cookieLife){
var today = new Date();
var expr = new Date(today.getTime() + cookieLife * 24 * 60 * 60 * 1000);
return expr.toGMTString();
}
// -->
</script>
Does anyone know why this cookie is not being set on my browsers? And 'yes' I have javascript enabled and I accept cookies. Any assistance will be greatly appreciated.
Thank you so much.