码迷,mamicode.com
首页 > 其他好文 > 详细

cookie的中文编码操作

时间:2015-09-21 12:11:21      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

 

关键的是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 "";
}

 

cookie的中文编码操作

标签:

原文地址:http://www.cnblogs.com/lmx22/p/4825454.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!