Return to Snippet

Revision: 61822
at January 16, 2013 22:10 by satie83


Initial Code
function get_cookies_array()
{
    var cookies = { };

    if( document.cookie && document.cookie != '' ) {
        var split = document.cookie.split( ';' );
        for ( var i = 0; i < split.length; i++ ) {
            var name_value = split[i].split( "=" );
            name_value[0] = name_value[0].replace( /^ /, '' );
            cookies[decodeURIComponent( name_value[0] )] = decodeURIComponent( name_value[1]    );
        }
    }

    return cookies;

}

Initial URL
http://www.electrictoolbox.com/javascript-get-all-cookies/

Initial Description
The following function loads all browser-cookies into an associative array with the cookie name as the index and the cookie value as the value

Initial Title
JavaScript - Get Cookies

Initial Tags
javascript

Initial Language
JavaScript