Cookie is saved on client side.
Response.Cookies["userName"].Value = "John"; Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1); HttpCookie cookie = new HttpCookie("lastVisit"); aCookie.Value = DateTime.Now.ToString(); aCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie);
Reading the Cookie
if(Request.Cookies["userName"] != null) Label1.Text = Server.HtmlEncode(Request.Cookies["userName"].Value);Above text is taken fromhttps://msdn.microsoft.com/en-us/library/ms178194.aspxType of Cookies?
Persist Cookie - A cookie with no expiry date is Persist Cookie Non-Persist Cookie - A cookie with expiry date is Non-Persist CookieState management is an art which retains user specific info between requests but most of the time the scope of info is global to entire app, To achieve the goal of state management in the app you may mix up the following client side state management options
- Control state
- Hidden fields
- ViewState
- Query strings