Geeks With Blogs
Fórmulas e Cenas Object Reference Not Set to an Instance of an Object
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.Expires = DateTime.Now + new TimeSpan(0, 1, 0, 0); // Set to expire in 1 day

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 :) Posted on Friday, January 30, 2009 10:46 AM Asp.Net , C# | Back to top

Comments on this post: Cookies anyone?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Sglima | Powered by: