I would like to offer just two options to my website visitors
1) accept all cookies and be able to navigate the website
2) refuse all cookies and not being able to navigate the website

so on clicking no thanks I would like to just redirect to a page which deletes all cookies and present a bye message. Can I do this with version 7.1.25 usung may be some custom code? If not it would be nice to implement this option in future.

Comments

oppure created an issue. See original summary.

svenryen’s picture

Status: Active » Fixed

Hi!

Thanks for your request. I understand you've done market research and found that visitors are not annoyed by the fact they can't use your site without accepting cookies, and that such a decision won't hurt brand or market reputation. :)

Assuming that your "bye message" is presented at the page "bye-bye.html", you can try this. It would immediately redirect visitors when they click "No" and would also redirect any subsequent attempts at browsing your web site.

(function($) {
  'use strict';
  $(function () {
    $(document).on('eu_cookie_compliance.changeStatus', function (event, status) {
      if (status === 0) {
        location.href = '/bye-bye.html';
      }
    });
    if (Drupal.eu_cookie_compliance.getCurrentStatus() === 0) {
      location.href = '/bye-bye.html';
    }
  });
})(jQuery);

Let me know if the above doesn't resolve your problem.

oppure’s picture

Hi Sven and thanks for your help, with this code what happens if the visitor wants to change his mind after clicking no? Will the visitor be able to go back and click "accept"?

Regarding "market research"... I run a personal website which provides informations for free, so far my tiny advertisement income didn't repay even a fraction of the money I've spent on the website, and that's without considering thhundreds of hours I've spent on it. I think it's quite understandable that I don't intend to spend (waste) any more time and work in trying to deal with this new (overly complicated and common sense lacking) cookies laws. The only option I have is to say "take it as it is or leave". To be honest I don't think I'm the only one in this situation and I would indeed suggest to implement this option in your excellent module.

regrds

svenryen’s picture

I understand your concern and headaches, and it's great that you're doing something to adhere to GDPR.

At the most basic, you can place this on your "bye-bye" page:

<div class="the-big-regret-button" onclick="jQuery.cookie('cookie-agreed', null, { path: '/' });">I regret and want advertisers to build profiles on my browsing habits</div>

To be frank, I think blocking access to content is a really bad user experience - when there are other options - , so unless there's an outcry here, there are no plans of implementing this feature.

The issue queue isn't a programming class, so if you need further consultation on Javascript coding I recommend drupal Slack chat (the support channel), Drupal stackexchange or drupal.org/forum.

oppure’s picture

Ok thanks.

oppure’s picture

Code in #4 didn't work for me, the following code worked:<button onclick="Cookies.remove('cookie-agreed', { path: '/' });">I accept cookies</button>
The only differences are the button html tag and the use of the newer js-cookie library instead of the jquery.cookie one. Of course jquery and js-cookie library must be loaded first.

oppure’s picture

I think similar code can be used to create a "withdraw cookie consent" page

<script type="text/javascript">
  function NoCookies(){
    Cookies.remove('cookie-agreed', { path: '/' });
    Object.keys(Cookies.get()).forEach(function(cookieName) {
    var Attributes = {path: '/', domain: 'yourdomain.com' };
    Cookies.remove(cookieName, Attributes);
    });
    var txt = '<p>Cookies consent withdrawn.</p>';
    $('body').append(txt);
  }
</script>

<button onclick= "NoCookies()">Withdraw cookies consent</button>

isinadinos’s picture

There is same problem on d8 version. How can this be fixed for d8?

Status: Fixed » Closed (fixed)

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

lo3001’s picture

Look which twig template you are using for eu_cookie_compliance, in my case "eu_cookie_compliance_popup_info.html.twig".

Copy this file in your theme template and modify
<button type="button" class="{{ secondary_button_class }}">{{ secondary_button_label }}</button>
to
<button type="button" class="{{ secondary_button_class }}" onclick="location.href='your link' ">{{ "your custom text"|t }}</button>