设置:
HttpCookie cookie = new HttpCookie("cookieName"); cookie.Value = "name1" HttpContext.Current.Response.Cookies.Add(cookie);
读取:
HttpContext.Current.Request.Cookies["cookieName"].Value
判断cookie是否存在:
if(HttpContext.Current.Request.Cookies["cookieName"]==null){ //do something }
设置cookie有效期
cookie.Expires = DateTime.Now.AddDays(1);
相关新闻
- 小程序登录流程图理解 2020-08-18
- 在C#中获取web.config中的配置信息 2021-08-23
- 小程序open-data头像样式 2021-04-10
- 小程序rich-text 富文本解析图片过大和图片路径的问题 2020-11-25
- C#中去掉字符串的最后一个字符 2020-11-23