// document.cookie = "name='张三';expires=time"
function setCookie(name, value, time) {
var now = new Date()
now.setDate(now.getDate()+time)//设置过期时间
document.cookie = name+'='+value+';expires='+now
}
function getCookie(name) {
var arr = document.cookie.split(';')
for (var i=0;i<arr.length;i++){
var arr2 = arr[i].split('=')
if(arr2[0] == name){
return arr2[1]
}
}
return ''
}
function removeCookie(name){
setCookie(name,11231321,-1)
}
setCookie("stu","张三",1)
setCookie("stu1","张三1",1)
// ['stu=张三', 'stu1=张三1']
// ['stu','张三']
// var cook = document.cookie
网友评论