4 回答

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊
//修改Cookie案例:
protected void Button3_Click(object sender, EventArgs e)
{
//獲取客戶端的Cookie對(duì)象
HttpCookie cok = Request.Cookies["MyCook"];
if (cok != null)
{
//修改Cookie的兩種方法
cok.Values["userid"] = "alter-value";
cok.Values.Set("userid", "alter-value");
//往Cookie里加入新的內(nèi)容
cok.Values.Set("newid", "newValue");
Response.AppendCookie(cok);
}
}

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊
Response.Cookies["xxx"].Value = "值";
讀取的時(shí)候最好是:
string abc="";
if(Request.Cookies["xxx"]!=null) //注意:這里不用Value
{
abc=Request.Cookies["xxx"].Value;
}
- 4 回答
- 0 關(guān)注
- 456 瀏覽
添加回答
舉報(bào)