How to create multiple cookies in mvc4?

Total Post:3

 2130  View(s)
Rate this:
How to create new cookie if the cookie is already create for same application?

Scenario: I have fetched the data and stored into session then cookie has created with session id.
second time i want to maintain different data in another cookie is it possible in mvc4?
  1. Post:36

    Re: How to create multiple cookies in mvc4?

    Hi Ganesh

    To write and read a single cookie with multiple key/values, it would look something like this:
    HttpCookie cookie = new HttpCookie("mybigcookie");
    cookie.Values.Add("name", name);
    cookie.Values.Add("address", address);
    //get the values out
    string name = Request.Cookies["mybigcookie"]["name"];
    string address = Request.Cookies["mybigcookie"]["address"];

      Modified On Apr-10-2018 02:37:18 AM