Click to See Complete Forum and Search --> : Cookie writing?


babylikesburgh
08-27-2008, 10:01 PM
Does anyone see anything wrong with this code?? I'm only wanting the cookie value to increase by 1 each postback, but for some reason it's not incrementing, it's stuck at 1. :confused:

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Request.Cookies("cookieCount") IsNot Nothing) Then
Dim userCookie As HttpCookie = Request.Cookies("cookieCount")
cookieLabel.Text = userCookie.Value
Else
Dim userCookie As New HttpCookie("cookieCount")
userCookie.Expires = Now.AddMonths(1)
Response.Cookies.Add(userCookie)
userCookie.Value = Int32.Parse(userCookie.Value) + 1
cookieLabel.Text = userCookie.Value
End If

End Sub



End Class

babylikesburgh
08-28-2008, 09:10 AM
Nevermind =)