PHPackages                             xddesigners/silverstripe-cookieconsent - 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. xddesigners/silverstripe-cookieconsent

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

xddesigners/silverstripe-cookieconsent
======================================

Cookie bar and consent checker for Silverstripe

6.0.2(7mo ago)0196↓100%BSD-3-ClausePHP

Since Sep 11Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/xddesigners/silverstripe-cookieconsent)[ Packagist](https://packagist.org/packages/xddesigners/silverstripe-cookieconsent)[ RSS](/packages/xddesigners-silverstripe-cookieconsent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

Silverstripe Cookie Consent
===========================

[](#silverstripe-cookie-consent)

GDPR compliant cookie bar and consent checker

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

[](#installation)

Install the module trough composer:

```
composer require xddesigners/silverstripe-cookieconsent
```

Include the popup template in your base Page.ss

```

```

Configuration
-------------

[](#configuration)

You can configure the cookies and cookie groups trough the yml config. You need to configure by provider, for providers the dots are converted to underscores e.g. ads.marketingcompany.com becomes ads\_marketingcompany\_com.

By configuring cookies trough yml you can check for consent in your code and make the necessary changes e.g. require the analytics or other cookies or skip placing them.

The texts for the configured cookies are editable trough the Site Config, here other cookies can also be added by CMS users. For example if a site user decides to embed a Youtube video he or she can specify the cookies that are placed by Youtube. I reccomend the following three groups to be created, these have default content, of course you are free to configure groups as you see fit.

```
XD\CookieConsent\CookieConsent:
  cookies:
    Necessary:
      local:
        - CookieConsent
        - ShowPopUp
    Marketing:
      ads_marketingcompany_com:
        - _track
    Analytics:
      local:
        - _ga
        - _gid
```

This module comes with some default content for cookies we've encountered before. If you want to set default content for these cookies yourself that is possible trough the lang files. If you have cookie descriptions that are not in this module, contributions to the lang files are much appreciated! Translations are managed trough [Transifex](https://www.transifex.com/xd/cookie-consent).

The files are structured as such:

```
en:
  CookieConsent_{provider}:
    {cookie}_Purpose: 'Cookie description'
    {cookie}_Expiry: 'Cookie expire time'
  # for cookies from your own domain:
  CookieConsent_local:
    PHPSESSID_Purpose: 'Session'
    PHPSESSID_Expiry: 'Session'
  # for cookies from an external domain:
  CookieConsent_ads_marketingcompany_com:
    _track_Purpose: 'Cookie description'
    _track_Expiry: 'Cookie expire time'
```

Then you can check for consent in your code by calling

```
if (CookieConsent::check('Analytics')) {
    // include google analytics
}
```

You can also configure the requirement of the default js and css. Make sure you combine at least the javascript in you bundle if you chose not to require by default!

```
XD\CookieConsent\CookieConsent:
  include_javascript: true
  include_css: true
  create_default_pages: true
```

### Enable XHR mode

[](#enable-xhr-mode)

When you use static publishing, you'll want to enable XHR mode. XHR mode accepts the cookies trough an xhr request and shows/hides the consent popup with the help of some javascript.

In your yml config set `xhr_mode` to `true`

```
XD\CookieConsent\CookieConsent:
  xhr_mode: true
```

In your javascript, you can make use of the utility class. This handles the xhr request and visibility of the popup:

```
import CookieConsent from '../vendor/xd/cookieconsent/javascript/src/cookieconsent';
const consent = new CookieConsent();
consent.enableXHRMode();
```

### Include assets in your bundle

[](#include-assets-in-your-bundle)

If you want to include the scss or js in your own bundle you can do that by:

```
// Import the CookieConsent utility
import CookieConsent from '../vendor/xd/cookieconsent/javascript/src/cookieconsent';

const consent = new CookieConsent();

// This tool let's you check for cookie consent in your js files before you apply any cookies
if (consent.check('Marketing')) {
  // add marketing cookie
}

// If you use Google Tag Manager this tool can also push the consent into the dataLayer object
consent.pushToDataLayer();
```

For the scss you can just import the scss file

```
@import "cookieconsent/scss/cookieconsent";
```

Make sure the relative paths to the files match your use case.

Default Pages
-------------

[](#default-pages)

This module also sets up 3 default pages on running dev/build. If you want to prevent that behaviour you should disable the `create_default_pages` config setting. The pages created are a CookiePolicyPage, PrivacyPolicyPage and TermsAndConditionsPage and are filled with bare bones content for each of the page types. *Of course it is your or your CMS users responsibility to alter these texts to make them fitting to your use case!*

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance72

Regular maintenance activity

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~24 days

Recently: every ~36 days

Total

7

Last Release

99d ago

Major Versions

4.0.0 → 5.0.02025-09-11

5.x-dev → 6.0.02025-09-11

### Community

Maintainers

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

---

Top Contributors

[![RVXD](https://avatars.githubusercontent.com/u/1586761?v=4)](https://github.com/RVXD "RVXD (32 commits)")

---

Tags

silverstripecookiebargdprconsent

### Embed Badge

![Health badge](/badges/xddesigners-silverstripe-cookieconsent/health.svg)

```
[![Health](https://phpackages.com/badges/xddesigners-silverstripe-cookieconsent/health.svg)](https://phpackages.com/packages/xddesigners-silverstripe-cookieconsent)
```

###  Alternatives

[bramdeleeuw/cookieconsent

GDPR compliant cookie bar and consent checker

1511.5k2](/packages/bramdeleeuw-cookieconsent)[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[silverstripe/userforms

UserForms enables CMS users to create dynamic forms via a drag and drop interface and without getting involved in any PHP code

1321.0M72](/packages/silverstripe-userforms)[codingfreaks/cf-cookiemanager

Manage cookies, scripts, and GDPR compliance on your Typo3 website with CodingFreaks Typo3 Cookie Manager. Customize cookie banners, streamline workflow, and enhance user experience. Ensure GDPR compliance and take control of cookie management with our Typo3 cookie management extension. Visit the official Typo3 Documentation page to learn more.

1625.8k](/packages/codingfreaks-cf-cookiemanager)

PHPackages © 2026

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