Forum Moderators: open
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim hc As New HttpCookie("test")
If hc IsNot Nothing Then
label.Text = ("Current Cookie value is " + Request.Cookies("test").Value + "<br />")
Else
label.Text = ("Current Cookie value is EMPTY!")
hc.Value = "Cookie Value"
hc.Expires = DateTime.Now.AddMinutes(2)
Response.Cookies.Add(hc)
End If
End Sub
Dim hc As New HttpCookie("test")hc will never be Nothing as you have just created it with 'New'
If hc IsNot Nothing Then
Probably not the best solution, but the following works:
Dim hc As New HttpCookie("test")
If Request.Cookies("test") IsNot Nothing Then
I've noticed that often a problem you are experiencing could be solved by using the Visual Studio debugger, which is a very powerful tool. (the best debugger I have ever come across in any Development Studio)
In case you are not experienced with it, here is a good Introduction to Debugging with Visual Studio [asp.net], and Debugging Tips and Tricks [msdn.microsoft.com]