Posted by : Deepak Vasudevan Tuesday, October 07, 2008

The most simplest way of detecting 'Cookies Enabled' with a User's Web Browser

The cookies are the most tastiest and most desired snacks for everyone. Even on the information highway, cookies are the most used to fill the gap of stateless HTTP. However, due to privacy and security reasons, many users may still opt for disabling the cookies. When we have our application constrained in such a way that cookie support is mandatory, we need to ensure that we seamlessly detect support of cookie in the web browser and alert user accordingly.

Fortunately, with JavaScript, a simple function call is enough to detect and tell whether cookie support is enabled or not.

<Script Language="JavaScript">
if (navigator.cookieEnabled)
alert ("Your web browser has cookies enabled");
alert ("Oops. Your web browser seems to be refusing cookies");

It is that simple as saying 1,2, 3 right?

One Response so far.

  1. David B says:

    Works, as long as they don't have Javascript disabled too. :)

    Thanks for the tip.

Popular Post

Blogger templates


Blog Archive


Blog Archive

Powered by Blogger.

- Copyright © Lavanya Deepak -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -