When writing web pages, you sometimes want to guarantee that the browser and user that are viewing the page accepts the cookies that you send. Though you can determine, with the Browser object, which browsers accept cookies, some browsers allow the user to refuse cookies even though the browser itself is capable of handling the cookie.
Here is some code that will assign a cookie and then check to make sure that it got assigned. Note that this page is called cookie.asp, changing the name will mean that you have to change the code where it references cookie.asp.
Response.Expires=0
strCookie = Request.Cookies("COOKIE")
strTry = Request.QueryString("Try")
If IsNull(strCookie) OR ( Len(strCookie) = 0) Then
' Check to see if this is a redirect after the cookie
' has been set
If IsNull(strTry) OR (Len(strTry) = 0) Then
Response.Cookies("COOKIE") = "Set"
' Redirect to this page and try again.
Response.Redirect("cookie.asp?Try=Yes")
Else
' User/Browser didn't accept cookies
' Do something...
Response.Redirect("bad.asp")
End If
End If