开发者

Updating a multi value cookie in ASP.NET MVC?

开发者 https://www.devze.com 2023-01-08 01:51 出处:网络
H开发者_如何转开发ow can I update a multi-value cookie in ASP.NET?public ActionResult ModifyCookie()

H开发者_如何转开发ow can I update a multi-value cookie in ASP.NET?


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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消