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.

Comments

artfulrobot created an issue. See original summary.

artfulrobot’s picture

StatusFileSize
new814 bytes
svenryen’s picture

Thanks for the patch. I'll take a look.

tr-drupal’s picture

Thanks for the patch, it worked for me too!

jollysolutions’s picture

Status: Active » Reviewed & tested by the community
millerrs’s picture

Patch in #2 seems to be working fine. It also fixes #2999592: Cookie message appears again after agreeing in IE11 for me.

svenryen’s picture

Thanks for the review. I will take a look and merge within a few weeks.

jcnventura’s picture

Indeed this fixed my continuously appearing cookie banner.

Please commit :)

jcnventura’s picture

StatusFileSize
new873 bytes
new1.1 KB

Actually, 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.

millerrs’s picture

Patch #9 works for me.

misthero’s picture

Patch #9 works. Thanks, I was trying to debug just this issue when I saw this patch.

jcnventura’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC as per #10 and #11

svenryen’s picture

This patch needs a port to D8.

svenryen’s picture

Here's an updated patch for D7 and a similar patch for D8.

  • svenryen committed 2710b7f on 8.x-1.x
    Issue #2994592 by jcnventura, svenryen, artfulrobot: Deletes cookies...

  • svenryen committed 8f99110 on 7.x-1.x
    Issue #2994592 by jcnventura, svenryen, artfulrobot: Deletes cookies...
svenryen’s picture

Status: Reviewed & tested by the community » Fixed
jcnventura’s picture

Thanks @svenryen!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.