user98914
user98914

Reputation: 71

Cookies in ASP.NET

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

Upvotes: 3

Views: 461

Answers (4)

Iralda Mitro
Iralda Mitro

Reputation: 7366

check this out

Save Form Data With Cookies

Upvotes: 4

Erick
Erick

Reputation: 6089

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";

Upvotes: 8

ChrisLively
ChrisLively

Reputation: 88072

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);

Upvotes: 5

Quentin
Quentin

Reputation: 944192

Google says "How to Write a Cookie"

Upvotes: 1

Related Questions