Cookie三步曲设置,取,移除(待完善)



//设置Cookie

function setCookie(key,value,t){

var date = new Date();

date.setDate(date.getDate()+t);

document.cookie=key+"="+value+";expires="+date;

}

//获取Cookie

function getCookie(key){

var arr = document.cookie.split("; ");

for(var i=0;i

var arr1 = arr[i].split("=");

if(arr1[0]==key){

return arr1[1];

}

}

}

//移除Cookie

function removeCookie(key){

setCookie(key,"",-1);

}

你可能感兴趣的:(Cookie三步曲设置,取,移除(待完善))