Alex-D/Cookies-EU-banner

banner not realod if cookie "hasConsent" set to false

sudhir600 opened this issue · 2 comments

Hi Alex, Great work.
BDW, I found a minor bug that, if any script or manually change cookie value "hasConsent=false" and then refresh the page, it didn't show cookie banner. when i simply empty the hasConsent value, it start showing banner. so my point is either empty value or false is convey the same meaning for banner. isn't?

why not put an eventLister,
I don't know how to listen cookie change but recently i work on how to detect any changes happen in LocalStorage.

window.addEventListener("storage", function (e) {
	//reload banner();
});

Hope you will find any solution for cookie for too.

image

Since the code contains that:

hasConsent: function () {
if (document.cookie.indexOf(this.cookieName + '=true') > -1) {
return true;
} else if (document.cookie.indexOf(this.cookieName + '=false') > -1) {
return false;
}
return null;
},

I did not understand how this cannot works :/

I did not think to add some watcher since it's not usefull in production.

As I re-read this issue, I think I understand your point: you are about to say that false and null are the same, but... no. False says that you decline; true, you accept, and null you had not make a choice yet.

So, behavior is OK and it's not a bug.