cookie的设置
function setCookie(key,value,options){
options=options||{};
var time="";
if(options.expires){
var d=new Date();
d.setDate(d.getDate()+options.expires);
time=“;expires=”+d;
{
var path="";
if(options.path){
path=";path="+options.path;
}
document.cookie=key+"="+value+time+path;
}
cookie的获取
function getCookie(key){
var arr=document.cookie.split(";");
var v="";
arr.forEach((val)=>{
if(val.split("=")[0]===key){
v=val.split("=")[1];
}
})
return v;
}
原文地址:https://www.cnblogs.com/bamboopanders/p/12076829.html
时间: 2024-10-10 18:14:13