ASP.NET中Cookie的操作
2013-01-10 23:10
246 查看
#region Cookie操作 /// <summary> /// 写cookie值 /// </summary> /// <param name="strName">名称</param> /// <param name="strValue">值</param> /// <param name="strValue">过期时间(分钟)</param> public static void WriteCookie(string strName, string strValue, int expires) { HttpCookie cookie = HttpContext.Current.Request.Cookies[strName]; if (cookie == null) { cookie = new HttpCookie(strName); } cookie.Value = strValue; cookie.Expires = DateTime.Now.AddMinutes(expires); HttpContext.Current.Response.AppendCookie(cookie); } /// <summary> /// 读cookie值 /// </summary> /// <param name="strName">名称</param> /// <returns>cookie值</returns> public static string GetCookie(string strName) { if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null) { return HttpContext.Current.Request.Cookies[strName].Value.ToString(); } return ""; } #endregion
相关文章推荐
- asp.net 操作Cookie 方法
- ASP.NET中对cookie的操作
- js操作cookie,asp.net后台删除cookie
- asp.net cookie的操作
- ASP.NET Cookie概念、CURD操作、原理、实际运用
- 关于asp.net c#中对cookie的操作
- 关于asp.net c#中对cookie的操作
- ASP.NET(c#)操作cookie、session、cache工具类
- ASP.NET 下的Cookie和Session 简单介绍与操作
- 深入解析javascript与asp.net对Cookie操作的异同,以及如何共用(一)。
- asp.net Cookie操作
- Asp.net 前后台操作cookie 实现数据的循环下载
- asp.net cookie的操作,写入、读取与操作
- ASP.NET cookie 操作详解cookie 写入、读取、修改、删除
- asp.net 操作Cookie和JS操作Cookie
- asp.net c#中对cookie的操作
- 学习心得:asp.net操作cookie
- ASP.NET cookie 操作详解cookie 写入、读取、修改、删除(增册改查)
- Asp.net中关于Cookie的操作
- ASP.NET实现Cookie功能的三个基本操作(写入,读取,删除)