A simpler cookie action class that can be easily invoked
With some simple application examples var axtic = axtic | | ... {} ;
Axtic. Cookies = ... {
/**//*
Function name: axtic. Cookie.get ([string name])
function function: Get cookie
Parameters: Name can be selected, the cookie names to be obtained
Description: Returns the value of the cookie name when all cookie,name are not empty when name is empty and returns undefined when there is no value
*/
Get:function (name) ... {
var CV = document.cookie.split (";"); /use "; The split cookie
var CVA = [], Cvat = [], Cvam = [], temp;
/**//* loop to get cookie name and value * *
for (i=0; i<cv.length; i++) ... {
temp = cv[i].split ("=");//split the name and value of the cookie with "="
if (Temp[0].indexof ("_divide_") > 0) ... {
Cvam[temp[0]] = temp[1];
}else ... {
if (Temp[0]!= "") cvat[i] = [temp[0], temp[1]];
}
}
for (i=0; i<cvat.length; i++) ... {
if (Cvat[i]) ... {
if (Cvat[i][1].substr (0,8)!= "^divide|") ... {
/**//* less than 4K cookie processing * *
Cva[cvat[i][0]] = unescape (cvat[i][1]);
}else ... {
/**//* greater than 4K cookie processing * *
var sta = cvat[i][1].indexof ("$"), tot = cvat[i][1].substring (8,sta);
Cva[cvat[i][0]] = cvat[i][1].substring (sta+1);
For (J=1 j<tot; j + +) ... {
Cva[cvat[i][0]] + + cvam[cvat[i][0]+ "_divide_" +j];
}
Cva[cvat[i][0]] = unescape (cva[cvat[i][0]);
}
}
}
if (name) return cva[name];//The cookie value of this name if there is a name
else return cva;//If no name is output with the name key, the value of the array
else return false;
},
/**//*
Function name: axtic. Cookie.set (string name, string value[, int expires[, string path[, String domain[, String secure]]]
function function: Depositing cookies
Argument: Name required, cookie name to be saved
Value required, the name of the cookie to be saved
Expires option, cookie expiration time, can be filled in seconds of the save time, can also fill in the date format (wdy, dd-mon-yyyy HH:MM:SS GMT) due time
Path option, cookie valid path on server side
Domain can be an option, the valid domain name for this cookie