Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR

Home Page:http://alex-d.github.io/Cookies-EU-banner/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

banner not realod if cookie "hasConsent" set to false

sudhir600 opened this issue · 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.