User24
User24

Reputation:

How do I find out if a user has cookies disabled in ASP.NET

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

Upvotes: 2

Views: 670

Answers (3)

Cerebrus
Cerebrus

Reputation: 25775

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).

Upvotes: 1

User
User

Reputation: 30945

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.

Upvotes: 1

Shoban
Shoban

Reputation: 23016

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

Upvotes: 0

Related Questions