如何在ASP.NET中更新多值cookie?
public ActionResult ModifyCookie()
{
// Read the cookie from the request
var cookie = Request.Cookies["cookieName"];
// Verify that the cookie was present
if (cookie != null)
{
// modify a value given the key
cookie.Values["key"] = "modified value";
// write the modified cookie back to the response
Response.AppendCookie(cookie);
}
return View();
}
Response.SetCookie(cookie)
Response.AppendCookie 只是将 cookie 添加到集合中。 - Captain Betty