c#后台读写Cookie


public class BaseCookies
{
#region Cookies
public static void SetCookieValue(string key, string value)
{
HttpCookie cookie = new HttpCookie(key, value);
cookie.Expires = DateTime.Now.AddDays(30);
//cookie.HttpOnly = true;
HttpContext.Current.Response.Cookies.Add(cookie);
}
public static string GetCookieValue(string key)
{
if (HttpContext.Current.Request.Cookies[key] == null)
{
return string.Empty;
}
else
{
return HttpContext.Current.Request.Cookies[key].Value;
}
}
#endregion
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM