当前位置: 代码迷 >> Web前端 >> Cookie相干(写入,读取,保存位置)
  详细解决方案

Cookie相干(写入,读取,保存位置)

热度:165   发布时间:2012-10-25 10:58:57.0
Cookie相关(写入,读取,保存位置)
关于Javascript写入与读取Cookie的方法如下所示:
function writeCookie(name, value, hours){
var expire = "";
if(hours != null){
  expire = new Date((new Date()).getTime() + hours * 3600000);
  expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}


//读取cookie
function readCookie(name){
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0){
  offset = document.cookie.indexOf(search);
  if (offset != -1){
   offset += search.length;
   end = document.cookie.indexOf(";", offset);
   if (end == -1) end = document.cookie.length;
   cookieValue = unescape(document.cookie.substring(offset, end))
  }
}
return cookieValue;
}

关于IE保存COOKIES的设置在哪里啊
C:\Documents and Settings\你的用户名\Cookies文件夹

  相关解决方案