Mega Code Archive

 
Categories / ASP.Net Tutorial / Page Lifecycle
 

Request Cookies

<script language="C#" runat="server" trace="true" > protected void Page_Load(object o, EventArgs e) { HttpCookie outbound = new HttpCookie("MyCookie"); HttpCookie inbound = Request.Cookies["MyCookie"]; if(inbound != null) {     outbound.Value = (Int32.Parse(inbound.Value) + 1).ToString();     theLabel.Text = inbound.Value; } else {     outbound.Value = "1"; } Response.Cookies.Add(outbound); } </script> <asp:label runat="server" id="theLabel" Text="no cookie value received" />