我使用以下代碼創建cookie,如何在另一個頁面中讀取txtusername值以及如何在單擊退出(註銷代碼)時刪除cookie。我是編程新手請幫忙。單擊退出時刪除Cookie
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
你真的不應該替換整個代碼就是這樣。這不是問題,因爲它是11分鐘前 –