c#cookie读取写入操作
public static void SetCookie(string cname, string value, int effective) { HttpCookie cookie = new HttpCookie(cname); cookie.Value = value; cookie.Expires = DateTime.Now.AddDays(effective); HttpContext.Current.Response.Cookies.Add(cookie); } public static object GetCookie(string cname) { HttpCookie cookie = HttpContext.Current.Request.Cookies[cname]; return cookie; } public static void RemoveCookie(string name) { HttpCookie cookie = HttpContext.Current.Request.Cookies[name]; if (cookie != null) { cookie.Expires = DateTime.Now.AddDays(-10); HttpContext.Current.Response.Cookies.Add(cookie); } }
从此山高路远,纵马扬鞭。愿往后旅途,三冬暖,春不寒,天黑有灯,下雨有伞。此生尽兴,不负勇往。