您的位置:首页 > 编程语言

Cookie 获取,设置的简短代码

2010-04-04 12:31 387 查看
代码

public string GetCookie(string cookie)

{

if (Request.Cookies[cookie] != null)

return Request.Cookies[cookie].Value;

return string.Empty;

}

public void SetCookie(string cookieName, string cookieValue, int expireDate)

{

HttpCookie cookie = new HttpCookie(cookieName);

cookie.Expires = DateTime.Now.AddDays(expireDate);

cookie.Value = cookieValue;

Response.Cookies.Add(cookie);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: