简单的cookie读写封装

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>简单的cookie封装</title>
</head>
<body>
</body>
<script>
var cookies={
name:this.name,
value:this.value,
day:this.day,
setCookie:function(name,value,day){
  var oDate=new Date;
       oDate.setDate(oDate.getDate()+day);
       document.cookie=name+'='+value+';expires=+'+oDate; 
},
getCookie:function(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 '';
}
removeCookie:function(name){
setCookie(name,1,-1);
}
}
cookies.setCookie('sex','男',10)
console.log(cookies.getCookie('sex'));
</script>
</html>
上一篇:python+requests+unittest执行自动化接口测试


下一篇:MySQL 的 read_buffer_size 参数是如何影响写缓冲和写性能的?