JavaScript读写Cookies

作者 佚名   摘自 未知   发表 2005-12-9 11:41:54  
 function setCookie(arg_CookieName,arg_CookieValue,arg_CookieExpireDays){
  var todayDate=new Date();
  todayDate.setDate(todayDate.getDate()+arg_CookieExpireDays);
  document.cookie=arg_CookieName+"="+arg_CookieValue+";path=/;expires="+todayDate.toGMTString()+";";
 
  }
 function getCookie(arg_CookieName){
  var Found=false;
  var start,end;
  var i=0;
  while(i <=document.cookie.length){
   start=i;end=start+arg_CookieName.length;
   if(document.cookie.substring(start,end)==arg_CookieName){
    Found=true;break;
   }
  i++;
  }
 
  if(Found==true){
   start=end+1;
   end=document.cookie.indexOf(";",start);
   if(end < start)end=document.cookie.length;
   return document.cookie.substring(start,end);
  }
  return "";
  
  }
原文地址:https://www.cnblogs.com/winner/p/340847.html