using System;
using System.Web;
/// <summary>
///session操作类
/// </summary>
public class appCookie
{
#region COOKIE 操作相关
/// <summary>
/// 写入Cookie
/// </summary>
/// <param name="strName"></param>
/// <param name="strValue"></param>
public static void WriteCookie(string strName, string strValue)
{
WriteCookie(strName, strValue, 30);
}
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.Domain = domain;
cookie.Value = strValue;
cookie.Expires = DateTime.Now.AddDays((double)expires);
HttpContext.Current.Response.AppendCookie(cookie);
}
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;
}
return "";
}
#endregion
}