MathCurvesSurfacesWallpaper GroupsGallerySoftwarePOV-Ray
ProgramingLinuxPerl PythonHTMLCSSJavaScriptPHPJavaEmacsUnicode ♥
Web Hosting by 1&1

JavaScript: Checking, Getting, Setting, Cookies

Xah Lee, ,

This page shows you how to check if cookies is enabled, and how to get, set, cookies.

Check Cookies is Enabled

Use the property navigator.cookieEnabled to see if cookies are enabled.

Sample code:

function ff() {
    if (navigator.cookieEnabled) {
        alert("yes cookies");
    } else {
        alert("no cookies");
    }
}

document.getElementById("ido2s68").onclick = ff;

The “navigator.cookieEnabled” is supported by all major browsers.

to see if your browser allow cookies.

Setting and Getting Cookie

To set a cookie, use document.cookie.

document.cookie="c1=3;c2=5";
document.cookie="c3=9";
alert("Your cookie: " + document.cookie);

to see your cookies.

blog comments powered by Disqus