Code has been added to clipboard!

Getting JavaScript Cookies

Example
function getCookie(cookName) {
    var cname = cookName + "=";
    var deCookie = decodeURIComponent(document.cookie);
    var cookArray = decodedCookie.split(';');
    for(var i = 0; i < cookArray.length; i++) {
        var c = cookArray[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(cname) == 0) {
            return c.substring(cname.length, c.length);
        }
    }
    return "";
}