What I’m trying to do is save 9 values from drop down boxes on my page into 9 cookies. These are the scripts I’m trying to use. SaveDefault gets the intital values and loops through the box elements. MyCookie() saves the values and SetCookie in theory should create the cookies.
The string is getting to this.cook at the bottom, but document.cookies does not seem to be saving it to the cookies folder on my computer. I don’t know if it’s a problem with the format of the cookie or a simple syntax problem.
As a side note, I have got the request and response.cookie objects to work in asp, but would rather do this client side.
function SaveDefault(){
var objForm = document.forms[0];
for (var i=0; i<9; i++){
MyCookie(‘set’,objForm.elements[i].id,objForm.elements[i].value,’30’,”/”,””,””);
}
}
function MyCookie(action,name,value,expires,path,domain,secure){
var action = action;
this.name = name;
if(action == ‘set’){
this.value = value;
this.expires = (expires)?expires:’-1′;
this.path = path || ‘/’;
this.domain = domain || document.domain;
this.secure = secure || ”;
this.today = new Date();
this.expr = new Date(this.today.getTime() + (this.expires * 86400000));
}
if(action == ‘set’){ this.set_cookie = SetCookie(this); }
else if(action == ‘get’){ this.cookie_value = GetCookieValue(this); }
else if(action == ‘all’){ this.dump = GetAllCookies(); }
}
function SetCookie(objCookie){
this.cook = objCookie.name + “=” + escape(objCookie.value);
this.cook += “?expires=” + objCookie.expr.toGMTString();
this.cook += “?path=” + objCookie.path;
this.cook += “?domain=” + Cookie.domain;
this.cook += “?” + objCookie.secure;
document.cookie = this.cook;
}