不是这样读吗? 
Request.Cookies["Name"].value;

解决方案 »

  1.   

    HttpCookie   MyCookie   =   new   HttpCookie( "table"); 
    MyCookie.Value   =   "yes";
    MyCookie.Expires = DateTime.Now.AddDays(1);
    Response.Cookies.Add(MyCookie); 
      

  2.   

    cookie存在安全隐患.不建议使用cookie.
    用session比较好
      

  3.   

    Request.Cookies["Name"].value;HttpCookie   MyCookie   =   new   HttpCookie( "table");  
    MyCookie.Value   =   "yes"; 
    MyCookie.Expires = DateTime.Now.AddDays(1); 
    Response.Cookies.Add(MyCookie); 红色地方的名称要一致
      

  4.   

     用这个方法试试 Response.AppendCookie();
      

  5.   

    取的时候可以这样string cookieValue = string.Empty;
    HttpCookie   MyCookie = Request.Cookies["table"];if (MyCookie != null)
        cookieValue = MyCookie.Value
      

  6.   

    是一致的~我刚刚是复制过来的所以没注意~~是什么原因啊?
    我设置完后Response.Redirect("其他页面")
    Request.Cookies["table"].value;
    报错对象不存在
      

  7.   

    你的代码没问题。如果取不到,可能是你的IE设置了不使用cookie吧
      

  8.   

    但是我用JS设置的cookies又能读到呀~那又是为什么呢?
      

  9.   


     //设置Cookie
     HttpCookie cookie = new HttpCookie("King");
     cookie.Value = "Test King";
     cookie.Expires = DateTime.Now.AddHours(1);
     Response.Cookies.Add(cookie);
     
     //读取Cookie
     HttpCookie cookie = Request.Cookies["King"];
     if (cookie != null)
     {
        Response.Write(cookie.Value);
     }
     else
     {
        Response.Write("Cookie is Null!");
     }
    测试可用!
      

  10.   

    你是在当前页面是吗? 那样他每次LOAD都会创建呀
    你跳到别的页面读一下~
      

  11.   

    我也遇到过类似的情况,我的现象是,在这个页面写的,在其他地方读的时候要等一会才会有结果,有时候时间短,有时候要几十秒之后才会显示结果
    我猜测是因为域名的问题,导致了cookie的读取比较慢,如果是其他问题,我实在想不出来原因了,正好可以讨论一下
      

  12.   

    先用FireFox的Web developer插件检查cookie是不是真的写进去了. 然后在看读取的问题.
      

  13.   

    Response.AppendCookie();
    我用这个添加行~为什么用Response.Cookies.Add(MyCookie);  又不行~为什么呀?
      

  14.   

    注意两点:
    1. 编码。
    2. 在没设置path的情况下,跨目录取不到值的。
      

  15.   

    #region "设置COOKIES"
        /// <summary>
        /// 设置COOKIES,包括值,做用域,有效路径,过期时间,字全级别
        /// </summary>
        /// <param name="cookies">COOKIES集合名称</param>
        /// <param name="items">集合中元素名,用,号分隔</param>
        /// <param name="values">集合中元素值,用|分隔</param>
        public void SetCookies(string cookies, string items, string values)
        {
            HttpCookie cookie = new HttpCookie(cookies);
            string[] item = items.Split(',');
            string[] value = values.Split('|');
            for (int i = 0; i < item.Length; i++)
            {
                cookie[item[i].ToString()] = value[i].ToString();
            }
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
        #endregion