The code in Drupal.behaviors.eu_cookie_compliance_popup_block_cookies defines a local variable euCookieComplianceBlockCookies to store a window.setInterval reference. That interval function deletes all but whitelisted cookies every 5s.
When you click Agree, it's supposed to delete that timer. However it because the function that does that check is in a different variable scope, it doesn't work.
The result is that you click agree, a cookie is added, then at some point up to a maximum of 5s later the cookie (and others) are deleted again. And next time you load a page you'll get annoyed by seeing the banner again.
The solution seems to be simply defining the variable in a shared scope, e.g. line 3 of eu_cookie_compliance.js
var euCookieComplianceBlockCookies;
And removing the "var" keyword before its assignment in Drupal.behaviors.eu_cookie_compliance_popup_block_cookies
This is working for me.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | eu_cookie_compliance-deletes-cookies-every-5min-2994592-14-8.x.patch | 1.13 KB | svenryen |
| #14 | eu_cookie_compliance-deletes-cookies-every-5s-2994592-14-7.x.patch | 1.13 KB | svenryen |
Comments
Comment #2
artfulrobot commentedComment #3
svenryen commentedThanks for the patch. I'll take a look.
Comment #4
tr-drupal commentedThanks for the patch, it worked for me too!
Comment #5
jollysolutionsComment #6
millerrs commentedPatch in #2 seems to be working fine. It also fixes #2999592: Cookie message appears again after agreeing in IE11 for me.
Comment #7
svenryen commentedThanks for the review. I will take a look and merge within a few weeks.
Comment #8
jcnventuraIndeed this fixed my continuously appearing cookie banner.
Please commit :)
Comment #9
jcnventuraActually, it didn't.
It seemed to work at the time, but further investigation turned up the fact that there seems to be some Drupal-8-like code in the code that detects the name of the cookie-agreed cookie. I've set that to the same condition used in the rest of the eu_cookie_compliance.js file.
Comment #10
millerrs commentedPatch #9 works for me.
Comment #11
misthero commentedPatch #9 works. Thanks, I was trying to debug just this issue when I saw this patch.
Comment #12
jcnventuraSetting to RTBC as per #10 and #11
Comment #13
svenryen commentedThis patch needs a port to D8.
Comment #14
svenryen commentedHere's an updated patch for D7 and a similar patch for D8.
Comment #17
svenryen commentedComment #18
jcnventuraThanks @svenryen!