4 回答
慕田峪9158850
TA贡献1794条经验 获得超8个赞
//修改Cookie案例:
protected void Button3_Click(object sender, EventArgs e)
{
//获取客户端的Cookie对象
HttpCookie cok = Request.Cookies["MyCook"];
if (cok != null)
{
//修改Cookie的两种方法
cok.Values["userid"] = "alter-value";
cok.Values.Set("userid", "alter-value");
//往Cookie里加入新的内容
cok.Values.Set("newid", "newValue");
Response.AppendCookie(cok);
}
}
catspeake
TA贡献1111条经验 获得超0个赞
Response.Cookies["xxx"].Value = "值";
读取的时候最好是:
string abc="";
if(Request.Cookies["xxx"]!=null) //注意:这里不用Value
{
abc=Request.Cookies["xxx"].Value;
}
添加回答
举报
0/150
提交
取消
