/ Published in: JavaScript
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
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }
URL: http://www.electrictoolbox.com/javascript-get-all-cookies/