PHPackages                             neophp/cookieconsent-package - 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. neophp/cookieconsent-package

ActiveLibrary

neophp/cookieconsent-package
============================

Cookie consent banner with optional database persistence for NeoPHP

v0.2.2(yesterday)06↑2900%MITPHPPHP &gt;=8.5CI passing

Since Aug 8Pushed yesterdayCompare

[ Source](https://github.com/NeoPHP-Dev/neo-cookieconsent-package)[ Packagist](https://packagist.org/packages/neophp/cookieconsent-package)[ RSS](/packages/neophp-cookieconsent-package/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

CookieConsent Package
=====================

[](#cookieconsent-package)

A cookie consent banner for NeoPHP, aligned with GDPR/ePrivacy expectations: configurable categories, cookie-based storage for anonymous visitors, and optional database persistence — with full history — when a user is logged in.

---

Structure
---------

[](#structure)

```
cookieconsent-package/
├── composer.json
├── README.md
├── src/
│   ├── NeoCookieConsentPackage.php
│   ├── Controllers/
│   │   └── CookieConsentController.php
│   ├── Service/
│   │   └── ConsentManager.php
│   ├── Assets/
│   │   ├── css/cookieconsent.css
│   │   └── js/cookieconsent.js
│   └── Templates/
│       └── components/
│           └── CookieConsent.macro.html.twig
├── config/
│   └── cookieconsent.config.php
└── database/
    ├── Entity/
    │   └── CookieConsentRecord.php
    ├── Repository/
    │   └── CookieConsentRecordRepository.php
    └── Migrations/
        └── MigrationVersion_CookieConsent_1.php

```

---

How storage works
-----------------

[](#how-storage-works)

- **Cookie (always)** — every consent choice is written to a browser cookie, readable instantly by JS without a server round-trip. This is the source of truth for anonymous visitors.
- **Database (optional, one row per consent given)** — if you pass a `$userType`/`$userId` pair when recording consent, a full history record is also persisted. Unlike `neo-twofactor-package` or `neo-permissions-package`, there is no unique constraint here — every consent action creates a new row, so you always have proof of what was accepted and when, even across changes.

This package never knows about your authentication system — you decide, in your own code, whether and when to pass user identity to `ConsentManager::recordConsent()`.

---

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

[](#installation)

```
php bin/neo package:require neophp/cookieconsent-package --project=MyProject
```

Register it in the project's `Config/app.config.php`:

```
return [
    // ...
    'packages' => [
        \Vendor\NeoPHP\CookieConsentPackage\NeoCookieConsentPackage::class,
    ],
];
```

Run the migration:

```
php bin/neo database:migration:migrate --project=MyProject
```

---

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

[](#configuration)

`config/cookieconsent.config.php` is copied once to `Config/Packages/CookieConsent/cookieconsent.config.php`:

```
