Return to Snippet

Revision: 14610
at June 7, 2009 18:20 by abwaters


Updated Code
function getCookie(name) {
    var cookies = document.cookie.split(/[; ]+/);
    for (var i = 0 ; i < cookies.length; i++) {
        if (cookies[i].substring(0,cookies[i].indexOf('=')) == name) {
            return cookies[i];
        }
    }
}

Revision: 14609
at June 7, 2009 17:33 by abwaters


Initial Code
function getCookie(name) {
    var theCookies = document.cookie.split(/[; ]+/);
    for (var i = 0 ; i < theCookies.length; i++) {
        var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
        if (aName == name) {
            return theCookies[i];
        }
    }
}

Initial URL
http://www.arachna.com/edu/tutorials/mini/cookies/javascript.html

Initial Description

                                

Initial Title
Getting a Cookie in Javascript

Initial Tags

                                

Initial Language
JavaScript