Cookie 获取,设置的简短代码
代码
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);
}
{
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);
}
走向地狱的途中,不小心走了程序员这条路,路上一个个黑心的老板,和暗无天日的加班,我才发现,通往地狱的路径中,我们这行是最短的。