Skip to content

Instantly share code, notes, and snippets.

@batazo
Created February 20, 2021 18:04
Show Gist options
  • Select an option

  • Save batazo/0663a8b47cd5b8f364bfc890e16b91a7 to your computer and use it in GitHub Desktop.

Select an option

Save batazo/0663a8b47cd5b8f364bfc890e16b91a7 to your computer and use it in GitHub Desktop.
Script can list all cookies in script domain
// https://electrictoolbox.com/javascript-get-all-cookies/
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;
}
console.log(get_cookies_array())
var cookies = get_cookies_array();
for(var name in cookies) {
document.write( name + " : " + cookies[name] + "<br />" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment