//设置cookie函数
function setCookie(key,value,t){
var oDate = new Date();
oDate.setDate( oDate.getDate() + t );
document.cookie = key + '=' + encodeURI(value) + ';expires=' + oDate.toGMTString();
}
//获取cookie函数
function getCookie(key){
//通过分号空格拆分开所有cookie
var arr1 = document.cookie.split('; ');
for (var i = 0; i < arr1.length; i++) {
//通过等号拆分单个cookie键值
var arr2 = arr1[i].split('=');
if( arr2[0]==key ){
return decodeURI(arr2[1]);
}
};
}
//删除cookie函数
function removeCookie(key){
setCookie(key,'',-1);
}