Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-06-04 15:01:40

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

GDPR Compliant Cookie Notice

There is a lot of discussion about this but it is scattered across a bunch of threads so I thought I would share what I came up with for now. You can see it in action over at Pate Technologies.

I wanted to users not to be tracked who hadn’t agreed or who had logged in to the backend. The code below is inside the head.

    <txp:if_logged_in not>
        <txp:oui_if_cookie name="acceptcookies">
                <txp:output_form form="google-global-site-tag" />
                <txp:output_form form="google-auto-ad-code" />
        </txp:oui_if_cookie>
    </txp:if_logged_in>

A lot of extra code here due to theme I am using but this is the modal that appears at the bottom of the screen. It should only appear once unless you go to the Cookies Policy where it will always appear giving the user the option to change their answer.

<txp:if_section name="cookies">
    .<txp:oui_cookie name="hidecookiemodal" delete="1" />
</txp:if_section>

<txp:oui_if_cookie name="hidecookiemodal">
<txp:else />
<txp:output_form form="cookie-functions" />
<div class="modal-strip modal-auto-open modal-bottom" data-delay="2500">
  <div class="container">
    <div class="row">
      <div class="vertical-align">
        <div class="col-md-8 text-sm-center sm-center sm-m-b-10 m-t-5">This website uses cookies to ensure you get the best experience on our website. <a href="https://patetech.info/cookies/" class="text-light"><span> More info <i class="fa fa-info-circle"></i></span></a></div>
        <div class="col-md-4 text-right sm-text-center sm-center">
          <button type="button" onclick="acceptcookies()" class="btn btn-light btn-rounded btn-outline btn-sm modal-confirm">Accept</button>
          <button type="button" onclick="declinecookies()" class="btn btn-light btn-rounded btn-outline btn-sm modal-confirm">Decline</button>
          <button type="button" class="btn btn-rounded btn-sm m-r-10 modal-close">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>
</txp:oui_if_cookie>

This is the javascript I wrote for cookie functions.

<script>
function acceptcookies() {
  document.cookie = "acceptcookies=yes; path=/";
  document.cookie = "hidecookiemodal=yes; path=/";
}

function declinecookies() {
  document.cookie = "acceptcookies=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
  document.cookie = "hidecookiemodal=yes; path=/";
}
</script>

I will probably revise this over time and I hope others will share their methods.

Offline

#2 2018-08-09 18:23:43

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,615
GitHub Twitter

Re: GDPR Compliant Cookie Notice

You can try this (old) plugin of mine (with no dependencies): https://github.com/cara-tm/pat_eu_cookies_law/releases/tag/v0.1.7


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#3 2018-08-10 06:37:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,028
Website GitHub Mastodon Twitter

Re: GDPR Compliant Cookie Notice

Pat64 wrote #313388:

You can try this (old) plugin of mine (with no dependencies): https://github.com/cara-tm/pat_eu_cookies_law/releases/tag/v0.1.7

This looks very cool.. I’ll try it over the weekend


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2018-08-10 09:15:22

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,615
GitHub Twitter

Re: GDPR Compliant Cookie Notice

Hi Yannis ;)

Please, note: latest pre-release version use HTML5 localStorage in order to store a marker corresponding of the choice of the users (widget injected into the HTML document with a micro template engine: works perfectly within modern browsers; the previous one use a Cookie instead (need a static markup into your HTML document): cross browsers.

I’m working on for a better cross browsers support.

Last edited by Pat64 (2018-08-10 09:16:34)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB