therealworld / cookieconsent-module
Cookie Consent Solution for OXID Shops
Package info
bitbucket.org/therealworld/cookieconsent-module
Type:oxideshop-module
pkg:composer/therealworld/cookieconsent-module
Requires
- php: ^8.3
- ext-json: *
- oxid-esales/oxideshop-ce: >=v7.4
- therealworld/tools-plugin: >=v3.9.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- v2.x-dev
- v2.3.0
- v2.2.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.19
- v2.0.18
- v2.0.17
- v2.0.16
- v2.0.15
- v2.0.14
- v2.0.13
- v2.0.12
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.1.33
- v1.1.32
- v1.1.31
- v1.1.30
- v1.1.29
- v1.1.28
- v1.1.27
- v1.1.26
- v1.1.25
- v1.1.24
- v1.1.23
- v1.1.22
- v1.1.21
- v1.1.20
- v1.1.19
- v1.1.18
- v1.1.17
- v1.1.16
- v1.1.15
- v1.1.14
- v1.1.13
- v1.1.12
- v1.1.11
- v1.1.10
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-master
- dev-oxid61
This package is auto-updated.
Last update: 2026-10-25 12:05:58 UTC
README
Deutsche Fassung: README.de.md

description
A cookie consent banner for the OXID shop. The shop operator maintains the cookies in the
admin and assigns each one a type (necessary, performance, functional, marketing). Visitors
accept all cookies, only the necessary ones, or choose per cookie. Templates ask
oViewConf.isAllowedCookie('<ident>') and only output a script when the visitor agreed to it.
- Composer package:
therealworld/cookieconsent-module - OXID module id:
trwcookieconsent
Requirements
- OXID eShop CE
>= 7.4, PHP^8.3,ext-json therealworld/tools-plugin>= 3.9.0- A Bootstrap 5 based theme: the banner is a Bootstrap modal with an accordion and is opened
through the global
bootstrap.Modal(data-bs-*attributes)
Installation
composer require therealworld/cookieconsent-module
vendor/bin/oe-console trw:module:setup trwcookieconsent
trw:module:setup (from therealworld/clirun-plugin) installs the module, runs its database
migration and activates it. Without the clirun-plugin: vendor/bin/oe-console oe:module:install vendor/therealworld/cookieconsent-module,
vendor/bin/oe-eshop-db_migrate migrations:migrate trwcookieconsent and
vendor/bin/oe-console oe:module:activate trwcookieconsent.
On activation the module
- switches on OXID's own option "show cookie notification" (
blShowCookiesNotification) for every shop — the banner is rendered through that core widget, so it stays hidden while the option is off - creates the CMS page
trwcookieconsentpopup(folder "user information") with placeholder title and text, unless it exists already
Configuration
Module setting
| Setting (admin) | Name | Default | Effect |
|---|---|---|---|
| Own cookies expiry time | numTRWCookieConsentExpires | 31536000 (1 year) | Lifetime in seconds of the module's own cookie trwcookieconsentallowedcookies, which stores the visitor's choice |
Banner text
Title and text of the banner come from the CMS page trwcookieconsentpopup
(Customer Info > CMS Pages). Replace the placeholder content in every language. The title is
also used as the label of the button that reopens the banner.
Cookies
Service > Cookie-Admin lists the cookies; New Cookie creates one. Per cookie:
| Field | Meaning |
|---|---|
| Active | Only active cookies are shown in the banner. The banner appears at all only when at least one active cookie exists in the current shop |
| Cookie ID | The ident the templates ask for (isAllowedCookie('googleanalytics')) |
| Cookie title | Label shown to the visitor (per language) |
| Cookie Type | necessary, performance, functional or advertising (shown as "Marketing") — the accordion groups of the banner |
| Sorting | Order within the banner |
| Cache-relevant | Folds the consent state of this cookie into the key of the static page cache (see below) |
Cookies of type necessary are always checked and cannot be deselected.
In multishop editions the shop's Mall tab gets the option "Inherit all (TRW) cookies from parent shop".
Frontend behaviour
- The stylesheet goes into the
<head>(blockhead_css), the banner itself is rendered at the end of the body (blockbase_js), so on a slow connection the page is painted first. It is not rendered onclearcookies,mallstartand plain popup pages (?plain=1). - As long as the visitor has not decided, the banner opens on its own. Afterwards a cookie button next to the mini basket reopens it.
- "Accept all", "select only Necessary" and "Save" send the choice in the background to
cl=CookieConsentDetailsController&fnc=setCookiesToSession; it is stored as JSON ({"<ident>": true|false}) in the cookietrwcookieconsentallowedcookies. - If the saved choice differs from the previous one, the page reloads, so server-side
isAllowedCookie()checks take effect immediately. An unchanged choice just closes the banner.
Using the consent in templates
{% if oViewConf.isAllowedCookie('googleanalytics') %}
{# tracking code #}
{% endif %}
oViewConf.showAllowedCookie() returns the full map, oViewConf.isCookieConsentActive() tells
whether the banner is in use in the current shop.
Static page cache
When a page is cached statically (e.g. by therealworld/staticcache-module), server-side
isAllowedCookie() checks would be frozen into the cache. Flag such cookies as
Cache-relevant: the module then contributes the accepted cache-relevant cookies to the cache
key, and each combination gets its own cache variant. Cookies whose scripts are switched on
client-side do not need the flag — every flagged cookie multiplies the number of variants.
Consent for other modules (consent contract)
The module implements the consent contract of the tools-plugin
(TheRealWorld\ToolsPlugin\Contract\ConsentProviderInterface). Modules that ask for consent
before tracking (e.g. therealworld/matomo-module) therefore need no dependency on this module -
and vice versa.
- The banner counts as in use as soon as the current shop has at least one active cookie
(
isConsentRequired()). Without an active cookie the module passes both questions on to the default provider: no consent required, everything allowed. hasConsent('<ident>', '<type>')looks up the cookie with this cookie ID and returns the visitor's choice (cookies of type necessary always true). If there is no cookie with that ID, consent to at least one cookie of the given type (performance,functional,advertising) is enough; without a type the answer is no.- For Matomo, create an active cookie with the ID
matomoand the type performance; with a static page cache also flag it Cache-relevant.
For developers
- Chain extensions:
Core\Language(registers the tabletrwcookieconsentas multi-language),Core\ViewConfig(isAllowedCookie(),showAllowedCookie(),isCookieConsentActive(),getTrwCookieConsentModuleId()),Application\Component\Widget\CookieNote(renders only when called withtrwcookieconsentposition=bodyend; the themes' own calls in the header render nothing). - Controllers: admin
cookieconsentcontroller,cookieconsentlist,cookieconsentmain; frontendCookieConsentDetailsController(fnc=setCookiesToSession, request arrayaAllowedCookies[<ident>]=0|1). - Services:
CookieConsentCacheKeyContributordecoratesTheRealWorld\ToolsPlugin\Contract\CacheKeyCookieContributorInterface,CookieConsentProviderdecoratesTheRealWorld\ToolsPlugin\Contract\ConsentProviderInterface. - Templates/blocks:
@trwcookieconsent/frontend/widget/header/cookieconsentnote.html.twigwith the blockscookieconsent_note,cookieconsent_note_head,cookieconsent_note_body,cookieconsent_note_body_welcome,cookieconsent_note_body_accordion,cookieconsent_note_body_accordion_item(_header|_body),cookieconsent_note_footer,cookieconsent_button; asset blockscookieconsent_assets_css,cookieconsent_assets_js,cookieconsent_assets_svg. Theme extensions:layout/base.html.twig,widget/minibasket/minibasket_button.html.twig, adminbottomnaviitem.html.twig,shop_mall.html.twig. - Database: table
trwcookieconsent(OXIDENT,OXTITLEmulti-language,OXTYPEenum,OXSORT,OXACTIVE,OXCACHERELEVANT), in PE/EE additionallytrwcookieconsent2shopandOXMAPID. Migrationmigration/data/Version20260711093100.php, migration tableoxmigrations_trwcookieconsent. The cookie types in the banner are read from the enum ofOXTYPE; a new type needs a migration plus a language constantTRWCOOKIECONSENT_TYPE_<TYPE>. - Assets: sources in
resources/(Vite, SCSS, vanilla JS), build output inassets/src/; seeresources/README.md.