Private Const SECURITY_COOKIE As String = "Security"
Private Const GUID_KEY As String = "GUID"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Cookie As HttpCookie = Request.Cookies.Item(SECURITY_COOKIE)
Dim Passed As Boolean
If Not (Cookie Is Nothing) Then
Dim GUID As String = Cookie.Item(GUID_KEY)
If GUID = String.Empty Then
CreateSecurityCookie()
Else
Passed = True
End If
Else
'always this line...always :o(
CreateSecurityCookie()
End If
Dim Woof As HttpCookie = Request.Cookies.Item(SECURITY_COOKIE)
If Woof Is Nothing Then
'never here as it's just been created above, so of course it exists
Passed = False
End If
End Sub
Private Sub CreateSecurityCookie()
Dim NewCookie As New HttpCookie(SECURITY_COOKIE)
Dim dt As DateTime = DateTime.Now
Dim ds As New TimeSpan(0, 0, 20, 0)
NewCookie.Expires = dt.Add(ds)
NewCookie.Item(GUID_KEY) = "Woof"
Request.Cookies.Add(NewCookie)
End Sub