日期:2014-05-17  浏览次数:20417 次

asp.net中关于Cookies
大家先看看我这代码:

if (rmbUser.Checked)//记住密码
               {
                   HttpCookie cook = new HttpCookie ("Cookie");
                   cook.Values.Add ("name", model.LoginId);
                   cook.Values.Add ("pwd", pwd.Text);
                   cook.Expires.Add (TimeSpan.FromDays (7));
                   Response.AppendCookie (cook);
               }
               else 
               {
                   HttpCookie ck = Request.Cookies["Cookie"];
                   if (ck != null)
                   {
                       ck.Expires = DateTime.Now.AddDays (-1);
                       Response.AppendCookie (ck);
                   }
               }



  
 if (Request.Cookies["Cookie"] != null) 
            {
                HttpCookie cookie=Request.Cookies["Cookie"] ;
                name.Text = cookie.Values["name"];
                pwd.Attributes.Add ("value", cookie.Values["pwd"]);
                rmbUser.Checked = true;
            }

问题是这样的,页面不关闭的前提下,正常退出后回到login页面,用户名和密码是记住的。但是,当把浏览器关闭后重新打开login页面后就不行了。why?
asp.net cookies

------解决方案--------------------