cookie操作

这里是cookie的设置,获得,及移除的一些简单操作;
function setCookie(name,value iDay){
     var sDate = new Date();
     sDate.setDate(sDate.getDate() + iDay);
     document.cookie=name + "=" + value + ";expries="+ sDate;
}

function getCookie(name){

     var arry =document.cookie.split(";");
     for(var i=0; i< arry.length; i++){
          var arry1 = arry[i].split("=");
           if(arry1[0]==name){
                  return arry1[1];
                }
     }
}


function removeCookie(name){
   setCookie(name,"-1",-1);
}

你可能感兴趣的:(cookie)