标签:style http color io ar sp 问题 c on
写入Cookie
protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie _ck = new HttpCookie("persion");
_ck.Value = HttpUtility.UrlEncode( "小杨");
_ck.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(_ck);
}
读取Cookie
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["persion"] != null)
{
string _s;
_s = Request.Cookies["persion"].Value;
Response.Write(HttpUtility.UrlDecode(_s));
}
}
红色标记不添加会导致读取Cookie“中文”乱码。
标签:style http color io ar sp 问题 c on
原文地址:http://www.cnblogs.com/lhfm56/p/4006750.html