I have a cookie –
LLBVAT
and the string in the cookie is (which can change, but the structure will remain the same):
So I know I’ll need to read the cookie, and then run a function on the returned string.
A0A64A06500000B754E9DD10B1381:0:false:false:99:9999:99:false:0:-1:0:0:0:EMAILPCD:1319094000000:82
I need to trigger a function on the second false (4th value).
Any help would be appreciated. thanks.
Is it possible to use less code:
function getCookie(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);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
split the value on
:the comparison is very important as
if ("false")is truthyGet a cookie from https://developer.mozilla.org/en/DOM/document.cookie
So then: