上传者: zkcharge
|
上传时间: 2021-11-23 17:07:58
|
文件大小: 18KB
|
文件类型: -
添加、修改、删除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;
}
}