cookies
This commit is contained in:
parent
5e34987209
commit
2540212723
1 changed files with 12 additions and 6 deletions
|
@ -1,10 +1,16 @@
|
|||
function getCookie(name) {
|
||||
nom = name + "=";
|
||||
let liste = document.cookie.split (';');
|
||||
for (let i = 0; i < liste.length; i++) {
|
||||
let c = liste[i];
|
||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
||||
if (c.indexOf(nom) == 0) return c.substring(nom.length, c.length);
|
||||
let lookingFor = name + "=";
|
||||
let arr = document.cookie.split(";");
|
||||
for(let str of arr)
|
||||
{
|
||||
while(str[0] == ' ') // removing potential unwanted spaces
|
||||
{
|
||||
str = str.slice(1);
|
||||
}
|
||||
if (str.slice(0,lookingFor.length)==lookingFor)
|
||||
{
|
||||
return str.slice(lookingFor.length);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
Loading…
Reference in a new issue