Navigator cookieEnabled Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Navigator

Description

The cookieEnabled property returns a Boolean value tells whether cookies are enabled in the browser.

Return Value

A Boolean, indicating whether cookies are enabled in the browser. Returns true if enabled, otherwise it returns false

The following code shows how to check if cookies are enabled in your browser:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from   w  w  w.  j  a v  a2s . c  om
    var x = "Cookies enabled: " + navigator.cookieEnabled;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials