您的当前位置:首页正文

js中cookie的添加、取值、删除示例代码_javascript技巧

2020-11-27 来源:汇智旅游网

代码如下:
function setCookie(name,value,time){
var oDate = new Date();
oDate.setDate(oDate.getDate()+time);
document.cookie = name+"="+value+";expires="+oDate;
}


function getCookie(name){
var arr = document.cookie.split("; ");
for(var i=0; ivar arr2 = arr[i].split("=");
if(arr2[0] == name){
return arr2[1];
}
}
return "";
}


function removeCookie(name){
setCookie(name,"",0)
}

显示全文