fm-labs / cakephp-cookieconsent
Cookie consent plugin for CakePHP
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=8.0
- cakephp/cakephp: ^4.0
Requires (Dev)
README
Cookie consent plugin for CakePHP
Uses the free javascript solution from osano/cookieconsent
https://github.com/osano/cookieconsent
Installation
composer require fm-labs/cakephp-cookieconsent
Usage
// Enable plugin in Application's boostrap method public function bootstrap() { // ... other boootstrap code $this->addPlugin('Cookieconsent'); }
Use helper in layout templates
// Example layout template <?php $this->loadHelper('Cookieconsent.Cookieconsent', ['autoRender' => false]); ?> <html> <body> <!-- ... other html code ... --> <?= $this->Cookieconsent->render(); ?> </body> <html>
Configuration
$this->loadHelper('Cookieconsent.Cookieconsent', [ 'autoRender' => true, 'block' => 'cookieconsent', 'palette' => [ 'popup' => ['background' => '#edeff5', 'text' => '#838391'], 'button' => ['background' => '#4b81e8'] ], 'type' => 'info', 'position' => 'bottom', 'revokable' => false, 'autoOpen' => true, 'law' => ['countryCode' => 'AT', 'regionalLaw' => true], 'location' => false, 'content' => [ 'header' => 'Diese Webseite benutzt Cookies.', 'message' => 'Diese Webseite benutzt Cookies um Ihnen die bestmögliche Nutzung unserer Services zu ermöglichen.', 'dismiss' => 'Verstanden', 'link' => 'Datenschutzerklärung', 'href' => '/datenschutz', ], 'cookie' => [ 'name' => 'cookie_law', 'path' => '/', //'domain' => null, 'expiryDays' => 365, ] ] );