IT Cookie Compliance

Categories

Component ID

2508371

Component name

IT Cookie Compliance

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

1678

Component created

Component changed

Component body

This module extends EU Cookie Compliance module to be compliant with the Italian
law, which requires the preemptive blocking of cookies when the user has not
still accepted the conditions.

How it works

This module adopts a lightweight fully server-side approach to exclude
Javascript files, blocks and node fields from any rendered page until the cookie policy has
been accepted.

Installation

1. Install and configure EU Cookie Compliance so that the popup is enabled
and viewable..
See https://www.drupal.org/project/eu_cookie_compliance.

2. Install IT Cookie Compliance.

3. Go to the admin/config/system/it-cookie-compliance page to configure the
javascript, blocks and fields to exclude before the acceptance.

Cached pages

Since the module operates server-side, when a page cache or reverse proxy system is enabled it must be aware of the agreement to return the correct version of the page (before and after the acceptance). This can be simply done by checking the value of the cookie "cookie-agreed", set by eu_cookie_compliance. When this cookie has value 2, the policy has been accepted.

It does not seem possible to get it work by code only with the standard Drupal cache working only by code without patching the core. See also https://www.drupal.org/node/322104.

A simple solution is to fool the caching system with some redirect when the
acceptance cookie is not found.
Add this rewrite rule in your .htaccess, before the all-redirect to index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{HTTP_COOKIE} !cookie-agreed=2 [NC]
RewriteCond %{QUERY_STRING} !cookie-not-accepted=1 [NC]
RewriteRule ^ %{REQUEST_URI}?cookie-not-accepted=1&%{QUERY_STRING} [L,R]