Thursday, March 29, 2012

Set Cookie

How do I set a cookie using C#?

code:
Response.Cookies["username"] = username.Text

It says it is read only.

this is VB.net but the idea should be the same..

Dim ckAsNew HttpCookie("test")
ck.Value ="junk"
Response.Cookies.Add(ck)


Here's how I modified it for C#: HttpCookie userCookie = new HttpCookie("username"); userCookie.Value = username.Text; Response.Cookies.Add(userCookie);

0 comments:

Post a Comment