I need to display a message if the user has cookies disabled. How would I go about doing this?
3 Answers
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.

- 30,403
- 22
- 79
- 107
-
-
1Unfortunately this is a business requirement. I'm a bit too lowly to question those. :) – Jul 17 '09 at 15:45
-
@User: well, I was using `Session_Start(){...}` to check `Request.AcceptedLanguages` and set – ANeves Aug 10 '11 at 15:08
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).

- 25,615
- 8
- 56
- 70
The only way is to store a value in cookie and check if you get the value back.

- 22,920
- 8
- 63
- 107