views:

155

answers:

4

I'm looking for a good example of storing data in a cookie using ASP.NET. Could someone show me an example?

+1  A: 

Google says "How to Write a Cookie"

David Dorward
A: 

check this out

Save Form Data With Cookies

DaDa
Exactly what part of that link had anything at all to do with .Net?
Chris Lively
+6  A: 

MSDN is quite your friend : http://msdn.microsoft.com/en-us/library/78c837bd.aspx

Until then :

C#:  
Response.Cookie["cookie_name"] = "value";

VB:  
Response.Cookie("cookie_name") = "value";
Erick
Please update answer with this link, http://msdn.microsoft.com/en-us/library/78c837bd.aspx. Site is only in en-US right now.
rick schott
+2  A: 

How to Create a cookie

HttpCookie mycookie = new HttpCookie("mycookie");
mycookie.Value = "chocolate chip please.";
Response.Cookies.Add(mycookie);

How to Read a cookie

HttpCookie mycookie = Request.Cookies["mycookie"];
Response.Write("Your cookie is: " + mycookie.Value);
Chris Lively