Skip to content

Instantly share code, notes, and snippets.

@Shimilbi
Last active September 23, 2023 00:01
Show Gist options
  • Save Shimilbi/25a21377ea735232541ce41c07873074 to your computer and use it in GitHub Desktop.
Save Shimilbi/25a21377ea735232541ce41c07873074 to your computer and use it in GitHub Desktop.
Lire un cookie
function getCookie(identifier) {
var valeur = document.cookie.split("&");
valeur.shift(); // (NB: Supprime le premier element d'un tableau et retourne sa valeur. La prochaine fois sera donc un autre cookie du meme document.)
var i=0;
while (i < valeur.length && valeur[i].split("=")[0] != identifier) i++;
if (i < valeur.length) return valeur[i].split("=")[1];
else return false;
}
@Shimilbi
Copy link
Author

JAMAIS de document.cookie = value. JAMAIS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment