hi i am getting errors when trying to set and read a cookie.
the set cookie code goes like this
function getexpirydate(nodays){
var UTCstring;
Today = new Date;
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring=Today.toUTCstring();
return UTCstring;
}
function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
}
i get the following error - object does'nt support this property or method on line 32 which happens to be the following
Today.setTime(nomilli+nodays*24*60*60*1000);
when i try to read the cookie i also get an error. the get cookie code is as follows
function getcookie(cookiename) {
var cookiestring=""+document.cookie;
var index1=cookiestring.indexOf(cookiename);
if (index1==-1 || cookiename==""{
return"";
window.location="login.htm";
}
var index2=cookiestring.indexOf(';',index1);
if (index2==-1) index2=cookiestring.length;
return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
var loggedin = getcookie("jpc"
if (loggedin!=true) window.location="login.htm";
the error i get is syntax error on line 41 which happens to be the following
if (loggedin!=true) window.location="login.htm";
any help that you could give would be great.
thanks
rose
the set cookie code goes like this
function getexpirydate(nodays){
var UTCstring;
Today = new Date;
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring=Today.toUTCstring();
return UTCstring;
}
function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
}
i get the following error - object does'nt support this property or method on line 32 which happens to be the following
Today.setTime(nomilli+nodays*24*60*60*1000);
when i try to read the cookie i also get an error. the get cookie code is as follows
function getcookie(cookiename) {
var cookiestring=""+document.cookie;
var index1=cookiestring.indexOf(cookiename);
if (index1==-1 || cookiename==""{
return"";
window.location="login.htm";
}
var index2=cookiestring.indexOf(';',index1);
if (index2==-1) index2=cookiestring.length;
return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
var loggedin = getcookie("jpc"
if (loggedin!=true) window.location="login.htm";
the error i get is syntax error on line 41 which happens to be the following
if (loggedin!=true) window.location="login.htm";
any help that you could give would be great.
thanks
rose