So, yesterday I was asked to create a cookie to store some information that could be used latter on.
I have never worked with cookies before and it was a nice surprise when google told me it was quite simple :)
To create a Cookie:
HttpCookie bolacha = new HttpCookie("CookieName");
bolacha.Values.Add("Key1",Value1);
bolacha.Values.Add("Key2",Value2);
bolacha.Expires = DateTime.Now + new TimeSpan(0, 1, 0, 0); // Set to expire in 1 day
Response.Cookies.Add(bolacha);
To Read a Cookie:
HttpCookie bolacha = Request.Cookies["CookieName"];
if (bolacha != null)
{
string value=bolacha.Values["Key1"]:
}
I think MS could not had made it any easier :)