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