添加、修改、删除cookie.
public class Cookie
{
///
/// 创建Cookies
///
/// Cookie 主键
/// Cookie 键值
/// Cookie 天数
/// Cookie ck = new Cookie();
/// ck.setCookie("主键","键值","天数");
public bool setCookie(string strName, string strValue, int strDay)
{
try
{
HttpCookie Cookie = new HttpCookie(strName);
Cookie.Expires = DateTime.Now.AddDays(strDay);
Cookie.Value = strValue;
System.Web.HttpContext.Current.Response.Cookies.Add(Cookie);
return true;
}
catch
{
return false;
}
}
1