PHPackages                             numero2/contao-cookie-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. numero2/contao-cookie-consent

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

numero2/contao-cookie-consent
=============================

A cookie consent solution for Contao CMS - the drop-in replacement for the cookie consent functionality of Contao Marketing Suite.

1.2.0(1mo ago)142↓63.6%LGPL-3.0+PHP

Since Apr 7Pushed 4w agoCompare

[ Source](https://github.com/numero2/contao-cookie-consent)[ Packagist](https://packagist.org/packages/numero2/contao-cookie-consent)[ RSS](/packages/numero2-contao-cookie-consent/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (12)Versions (5)Used By (0)

Contao Cookie Consent Bundle
============================

[](#contao-cookie-consent-bundle)

[![Packagist Version](https://camo.githubusercontent.com/43839a48a307fb1493ff712e8f007688907161d8feea1a2fc2b1f47ef246c8aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e756d65726f322f636f6e74616f2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/numero2/contao-cookie-consent)[![License: LGPL v3](https://camo.githubusercontent.com/378367a0f32c18d4cd4a72c592d665bb27e3c184419e2fa85ff21fde8972bc1a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4c47504c25323076332d626c75652e7376673f7374796c653d666c61742d737175617265)](http://www.gnu.org/licenses/lgpl-3.0)

A cookie consent solution for Contao CMS - the drop-in replacement for the cookie consent functionality of [Contao Marketing Suite](https://github.com/numero2/contao-marketing-suite).

---

Screenshot
----------

[](#screenshot)

[![Cookie Consent in Light and Dark mode](./docs/screenshot-consent.png)](./docs/screenshot-consent.png)

> Cookie Consent in Light and Dark mode

---

Requirements
------------

[](#requirements)

- [Contao](https://github.com/contao/contao) **5.7 or newer**

---

Installation
------------

[](#installation)

Via **Contao Manager** or **Composer**:

```
composer require numero2/contao-cookie-consent
```

---

Insert Tags
-----------

[](#insert-tags)

Use these insert tags directly in your Contao templates and content elements to control cookie consent dependent output.

TagDescription`{{cc_optinlink}}`Renders a link that reopens the cookie consent dialog, allowing the user to adjust their consent. After confirming, the page scrolls back to the original element automatically.`{{ifoptin::*}}`Wraps content that is only shown if the user **has accepted** the specified tag. Replace `*` with the tag ID.`{{ifnoptin::*}}`Wraps content that is only shown if the user **has not accepted** the specified tag. Replace `*` with the tag ID.### Examples

[](#examples)

```
{{ifoptin::6}}You have accepted ACME cookies.{{ifoptin}}

{{ifnoptin::6}}Please accept ACME cookies to see this content.{{ifnoptin}}

```

---

Styling
-------

[](#styling)

### Colors

[](#colors)

Colors can be customized via CSS custom properties. Example:

```
cc-cookie-consent, cc-cookie-optin {
    --cc-accent: #f47c00;
}
```

> A full list of available CSS custom properties can be found in [contao/templates/styles/cc\_default.html.twig](contao/templates/styles/cc_default.html.twig).

### Color scheme

[](#color-scheme)

By default, both elements follow the color scheme defined by the user's operating system or browser. If your page layout requires a specific scheme, it can be enforced via a custom template:

```
{% extends '@Contao/frontend_module/cc_cookie_consent.html.twig' %}

{% set attributes = attrs(attributes|default)
    .set('color-scheme', 'light')
%}
```

---

Developer API
-------------

[](#developer-api)

This bundle exposes helper utilities to check cookie consent status programmatically - both in PHP/Symfony and in Twig templates.

### PHP / Symfony

[](#php--symfony)

Inject the `numero2_cookie_consent.util.cookie_consent` service into your controller or service:

```
// src/Controller/MyCustomController.php
namespace App\Controller;

use numero2\CookieConsentBundle\Util\CookieConsentUtil;

class MyCustomController
{
    public function __construct(
        private readonly CookieConsentUtil $cookieConsentUtil
    ) {}

    public function __invoke(): void
    {
        // Returns true if the tag with ID 6 has been accepted
        $this->cookieConsentUtil->isTagAccepted(6);

        // Returns true if the tag with ID 6 has NOT been accepted
        $this->cookieConsentUtil->isTagNotAccepted(6);

        // Generates a link that triggers the consent dialog
        $this->cookieConsentUtil->generateConsentForceLink();
    }
}
```

### Twig

[](#twig)

Three global Twig functions are available:

```
{# Show content only if tag ID 6 was accepted #}
{% if cc_tag_accepted(6) %}
    Analytics is enabled.
{% endif %}

{# Show content only if tag ID 6 was NOT accepted #}
{% if cc_tag_not_accepted(6) %}
    Please enable Analytics to see this content.
{% endif %}

{# Render a fallback optin dialog for the given tag #}
{{ cc_tag_fallback(6) }}

{# Render a link that opens the consent dialog (optional: custom CSS ID) #}
{{ cc_consent_force_link('customCSSId') }}
```

### HTTP-Cache

[](#http-cache)

Should work as expected for other Contao entities such as content elements, modules, articles, pages, etc. This means that whenever a tag or tag group is created, edited, or deleted, the corresponding cache entries will be invalidated.

However, be aware that we do not support cache invalidation based on function usage, e.g. `$this->cookieConsentUtil->isTagAccepted()`, or in Twig `{% if cc_tag_not_accepted() %}`. Also, the insert tag `{{ifoptin::}}` can only affect the rendered markup based on the tag configuration itself.

---

Disclaimer
----------

[](#disclaimer)

### Cookie storage

[](#cookie-storage)

This bundle manages cookie consent on behalf of your Contao installation. Any cookies set during the consent process belong to **your website** - no data is transmitted to or stored by us.

The following cookies are set by this bundle:

CookieValueLifetimePurpose`cc_cookies`List of tag group IDs7 days by default, configurableStores which tag groups the user has accepted (if any).#### Consent Logs

[](#consent-logs)

This bundle does not maintain any server-side logs of individual user consent. As the extension does not require user accounts, it is technically impractical to link a consent decision to a specific individual or IP address. Instead, user consent - or rejection - is recorded exclusively via a cookie stored on the user’s device. This approach ensures that consent can be reliably verified for each user while avoiding the storage of personal data on the server, in line with GDPR principles of data minimization and privacy by design.

### Legal stuff

[](#legal-stuff)

Please use this bundle at your own risk. Whether your specific setup is legally compliant is something we cannot assess - if you're uncertain, a lawyer is the right contact. For technical questions, though, we're happy to help.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance94

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 72.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

4

Last Release

35d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab9bf091a6e23befeea4ccbf34fcfb0da22a14f6ec94df20664e7b149fd4ed74?d=identicon)[numero2](/maintainers/numero2)

---

Top Contributors

[![bennyborn](https://avatars.githubusercontent.com/u/226890?v=4)](https://github.com/bennyborn "bennyborn (8 commits)")[![michb](https://avatars.githubusercontent.com/u/17873830?v=4)](https://github.com/michb "michb (3 commits)")

---

Tags

consentcontaocookiedsgvogdprcontaocookiegdprconsentdsgvocookieconsentopt incookiebar

### Embed Badge

![Health badge](/badges/numero2-contao-cookie-consent/health.svg)

```
[![Health](https://phpackages.com/badges/numero2-contao-cookie-consent/health.svg)](https://phpackages.com/packages/numero2-contao-cookie-consent)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M374](/packages/easycorp-easyadmin-bundle)[contao-community-alliance/dc-general

Universal data container for Contao

1579.5k90](/packages/contao-community-alliance-dc-general)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M518](/packages/shopware-core)[metamodels/core

MetaModels core

9956.1k68](/packages/metamodels-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
