js里对php存贮的cookie进行读取和删除

/* 读取cookie */
function getCookie(name){
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  if(arr=document.cookie.match(reg))
    return unescape(arr[2]);
  else
    return null;
}

/* 清除cookie */
function delCookie(name){
  var date=new Date();
  date.setTime(date.getTime()-10000);
  document.cookie=name+"=v; expire="+date.toGMTString()+"; path=/";
}

原文地址:https://www.cnblogs.com/rickons/p/4956046.html