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 "";
  
  }
posted @ 2006-03-02 09:25  Winner.Net(2007)  阅读(425)  评论(0编辑  收藏  举报