2

I need to display a message if the user has cookies disabled. How would I go about doing this?

  • 1
    Dup: http://stackoverflow.com/questions/531393/how-to-detect-if-cookies-are-disabled-is-it-possible – rahul Jul 17 '09 at 09:44

3 Answers3

1

Save some test value and try to re-read it at the next request.

But honestly, your approach is not user friendly. There is hardly any technical reason to deny a service with cookies disabled. You can fall gracefully and just store the values in session.

Anyway, if a user has "In-private" browsing mode on (now available in both IE & FF meaning almost all users) your cookies will anyway be gone after the user's done and there is no way you can detect the "in-private" mode.

User
  • 30,403
  • 22
  • 79
  • 107
1

You can check the Request.Cookies property which would return an empty HttpCookieCollection.

In Javascript, the usual way to check is the Navigator.cookieEnabled property (works on IE, for other browsers, I think you need to set a cookie and try to read back its value).

Cerebrus
  • 25,615
  • 8
  • 56
  • 70
0

The only way is to store a value in cookie and check if you get the value back.

Shoban
  • 22,920
  • 8
  • 63
  • 107