//set cookies
HttpCookie myCookie = new HttpCookie("UserSettings");
myCookie["sn"] = "******";
myCookie.Expires = DateTime.Now.AddDays(1d);
Response.Cookies.Add(myCookie);
//read cookies
string a = Request.Cookies["UserSettings"]["sn"];
//MSDN 嚴謹的作法
if (Request.Cookies["UserSettings"] != null) { string userSettings; if (Request.Cookies["UserSettings"]["Font"] != null) { userSettings = Request.Cookies["UserSettings"]["Font"]; } }
沒有留言:
張貼留言