1. 程式人生 > >asp.net之cookie

asp.net之cookie

color quest div 獲取cookie cnblogs tpc .net http 創建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();

asp.net之cookie