用 document.cookie获取的值 "asdf; yang=zhang@zhang=yang; login=; CNZZDATA30060591=cnzz_eid=74209175-1351044555-&ntime=1351127145&cnzz_a=6&retime=1351128059098&sin=&ltime=1351128059098&rtime=1; sdmenu_my_menu=1000000000000000000000000000000; CNZZDATA30059169=cnzz_eid=83058028-1350979372-&ntime=1351231159&cnzz_a=3&retime=1351232077380&sin=&ltime=1351232077380&rtime=2; CNZZDATA30049607=cnzz_eid=99745689-1350632931-&ntime=1351506112&cnzz_a=4&retime=1351506156046&sin=http%253A%252F%252Flocalhost%253A25543%252Fddt%252Findex.aspx&ltime=1351506156046&rtime=5; CNZZDATA1284672=cnzz_eid=4407617-1350530632-&ntime=1351507594&cnzz_a=12&retime=1351507583680&sin=http%253A%252F%252Flocalhost%253A25543%252Fddt%252Findex.aspx&ltime=1351507583680&rtime=5; [email protected]"
这里面为什么没有获取到Name为 userinfo 的cookie的值 

解决方案 »

  1.   

    没看到有Name=userinfo的字符串啊
      

  2.   

     为了证明userinfo存在  我才故意截图 的啊  图片中 name列 倒数第四行不就是吗??
      

  3.   

    你没把 userinfo 放到cookie吧
      

  4.   

    用现成的方法吧:var CookieUtil = {
    //read cookie:
    // Example:
    // alert( readCookie("myCookie") );
    readCookie : function(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;
    } //write cookie:
    // writeCookie("myCookie", "my name", 24);
    // Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
    // The hours parameter is optional; if hours is left out, the cookie value expires at the end of the visitor's browser session.
    ,writeCookie : function(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;
    }

    }