1.創建cookie 2.獲取cookie ...
1.創建cookie
HttpCookie userCookie = new HttpCookie("userInfo"); userCookie["name"] = Request.Form["username"].ToString(); userCookie["pwd"] = Request.Form["pwd"].ToString(); userCookie.Expires = DateTime.Now.AddHours(1); //設置過期時間 Response.SetCookie(userCookie);
2.獲取cookie
Request.Cookies["userInfo"]["name"].ToString();