To check the cookie enabled you can use the javascript code in the web page header to send the alert message to the user for enabling the browser cookies.

What are cookies? Cookies are small text files that server sends to the client’s browser to store some text message at the client end. Generally, cookies are used to store the website or user information on client’s PC that is frequently used on the web pages e.g. username, shopping carts etc. Cookies are also used to track the visitors, visitor’s loyalty for tracking returning or new visitors. Cookies also provide the help in the web site login feature of remember me to auto login the user next time when he visits the site from the same PC.

To perform the above actions by using cookies is only possible if the client’s browser is cookie enabled.

Javascript navigator Object can be used to detect whether the browser cookies are enabled or not.

Javascript Code to check cookieEnabled

<html>
<head>
    <title>detect browser cookies</title>

    <script language="javascript" type="text/javascript">
    <![CDATA[
        function detect() {
            if (navigator.cookieEnabled) {
                alert('Your browser has cookies enabled.');
            }
            else {
                alert('Your browser has cookies disabled.');
            }
        }
    ]]>
    </script>
</head>
<body onload="detect();">
</body>
</html>

Continue to next tutorial: Javascript Browser Detection to learn how to detect web browser.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.