标签:main getc func document length domain etc doc function
//存cokie
function setcookie(keys,value,time){
document.cookie=keys+"="+decodeURIComponent(value)+"domain=127.0.0.1;max-age="+time;
}
cookie的案例
//取cookie
function getcookie(keys){
var arr=document.cookie.split(";");
for(var i=0;i<arr.length;i++){
var ass=arr[i].split("=");
if(ass[0].trim()==keys){
return ass[1];
}
}
return false;
}
//删cookie
function delcookie(){
var arr=document.cookie.split(";");
for(var i=0;i<arr.length;i++){
var ass=arr[i].split("=");
document.cookie=ass[0]+"=;max-age=0"
}
}
标签:main getc func document length domain etc doc function
原文地址:https://www.cnblogs.com/shangjun6/p/10205521.html