faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 10 people (100%) answered Yes
Recently 8 of 8 people (100%) answered Yes

Entry

Is there anyway to determine whether a browser can accept cookies?

Jul 10th, 2000 05:56
unknown unknown, Phil Smith


<%
        Dim strCookie, strTry
           strCookie = Request.Cookies("MyCookie")
           strTry = Request.QueryString("Try")
        If strCookie = "" Then
          ' Check to see if this is a redirect
          ' after setting the cookie
          If strTry = "" Then
                 Response.Cookies("MyCookie") = "Set"
                 ' Redirect to this page and try again.
Response.Redirect(Request.ServerVariables("SCRIPT_NAME") & "?Try=Yes")
          Else
                 '  User/Browser didn't accept cookies
                 '  Do something...
                 Response.Write "Cookies are off.  You'd be redirected 
to a page telling 
you how to turn them on."
          End If
        Else
          ' -- Hooray! User is accepting cookies
          ' -- Delete our cookie: by setting its
          ' -- expiry date to waaaay back
          Response.Cookies("MyCookie").Expires = "January 1, 1980"
                 '  Do something...
          Response.Write "Cookies are on.  Come in and shop."
        End If
%>



© 1999-2004 Synop Pty Ltd