生成个Cookies,记录访问过我的网站还有用JS删除某个Cookies  
菜鸟 怎么做

解决方案 »

  1.   

    常用的3个方法function SetCookie(sName, sValue)
    {
      document.cookie = sName + "=" + escape(sValue);
      var date = new Date();
      date.setMonth(date.getMonth()+1);
      document.cookie += ("; expires=" + date.toUTCString()); 
    }
    function GetCookie(sName)
    {
      var aCookie = document.cookie.split("; ");
      for (var i=0; i < aCookie.length; i++)
      {
        // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) 
          return unescape(aCrumb[1]);
      }
      // a cookie with the requested name does not exist
      return null;
    }function DelCookie(sName)
    {
      document.cookie = sName + "=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
    }
      

  2.   

    不是js能不能操作file,而是浏览器不会让js操作本地file。否则互联网就是病毒木马的天下。
    删除cookie也就是设置其过期,也就是一楼的代码。
      

  3.   

    这种操作应该是 操作浏览器中的cookie吧??请问,本地js能不能操作cookies文件呢?在本地使用 document.cookie后,其长度为0?