Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR
http://alex-d.github.io/Cookies-EU-banner/
MIT License
441 stars 57 forks source link

banner not realod if cookie "hasConsent" set to false #37

Closed sudhir600 closed 5 years ago

sudhir600 commented 6 years ago

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

Alex-D commented 6 years ago

Since the code contains that:

https://github.com/Alex-D/Cookies-EU-banner/blob/87f64f64e6c3d4c25616fd9edbfd27af9fbf3ebc/src/cookies-eu-banner.js#L95-L103

I did not understand how this cannot works :/

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

Alex-D commented 5 years ago

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.