dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
May 2, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Finding Out if a User Has Disabled Cookies

Question:
How do I find out if a user has disabled cookies?

Answer:

To find out if a user has disabled cookies, follow these steps:

  1. Set a cookie.
  2. Redirect to your own page.
  3. In the redirect, read the cookie.
  4. If your cookie has a value, user has enabled cookies. If there is no value, then the user has disabled cookies.
  5. Use the Querystring to determine if you are on step 1 or step 3.

To set the cookie, use the following code:

   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... 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... End If

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date