I'm trying to get exist cookie with the following code:
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
console.log(c);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
I have the cookie name but i'm always getting NULL.
I see the cookie at the developer tool (https://developers.google.com/web/tools/chrome-devtools/manage-data/cookies)
but document.cookie
is ""