标签:
关键的是Server.UrlEncode()、Server.UrlEncode() 这2个方法
public void SetCookie(string CookieName, string CookieValue, int CookieDays)
{
HttpCookie ctrCookie;
if (Request.Cookies[CookieName] == null)
{
ctrCookie = new HttpCookie(CookieName);
}
else
{
ctrCookie = Request.Cookies[CookieName];
}
ctrCookie.Value = Server.UrlEncode(CookieValue);
ctrCookie.Expires = DateTime.Now.AddDays(CookieDays);
Response.Cookies.Add(ctrCookie);
}
public string GetCookie(string CookieName)
{
if (Request.Cookies[CookieName] != null)
return Server.UrlDecode(Request.Cookies[CookieName].Value);
else return "";
}
标签:
原文地址:http://www.cnblogs.com/lmx22/p/4825454.html