怎样修改cookies 中的值 C#

怎样修改cookies 中的值 C#


POPMUISE
浏览 1234回答 3
3回答

拉莫斯之舞

 //修改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);  }  }

月关宝盒

Response.Cookies["xxx"].Value = "值";读取的时候最好是:string abc="";if(Request.Cookies["xxx"]!=null) //注意:这里不用Value{abc=Request.Cookies["xxx"].Value;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Ruby