LaravelPackages.net
Acme Inc.
Toggle sidebar
nickdekruijk/cookie-consent

A simple cookie accept popup for EU laws

70
1
3.1.0
About nickdekruijk/cookie-consent

nickdekruijk/cookie-consent is a Laravel package for a simple cookie accept popup for eu laws. It currently has 1 GitHub stars and 70 downloads on Packagist (latest version 3.1.0). Install it with composer require nickdekruijk/cookie-consent. Discover more Laravel packages by nickdekruijk or browse all Laravel packages to compare alternatives.

Last updated

Cookie Consent for Laravel

According to EU laws visitors should opt-in for all non essential cookies. This package adds a simple 'Accept Cookies' popup to your Laravel Application.

Installation

To install package use

composer require nickdekruijk/cookie-consent

Publish the config file in case you want to customize it

php artisan vendor:publish --provider=NickDeKruijk\\CookieConsent\\CookieConsentServiceProvider

Frontend

Add this to every view/page where you want to show the popup

@include('cookieconsent::show')

And wrap any code that places tracking cookies/pixels/code with the cookieConsentAccepted() helper, for example like this:

@if (cookieConsentAccepted())
// Your tracking code here
@endif

And style the popup as you like, for example:

.cookieconsent-container {position:fixed;bottom:0;left:0;right:0;background-color:red;text-align:center;padding:50px;z-index:9999;color:#fff}
.cookieconsent-close {position:absolute;top:0;right:0;color:red;font-size:50px;padding:10px;line-height:.7;font-weight:bold;display:block}
.cookieconsent-button {display:inline-block;padding:10px 20px;border:2px solid #fff;border-radius:5px;text-decoration:none;color:inherit;margin:10px}
.cookieconsent-button:hover {background-color:rgba(255,255,255,0.5)}
.cookieconsent-button-accept {background-color:#fff;color:red}
.cookieconsent-button-accept:hover {background-color:rgba(255,255,255,0.8)}

Changing text/localization

To change te tekst/buttons/info link copy the files from https://github.com/nickdekruijk/cookie-consent/tree/master/src/translations to /resources/lang/vendor/cookieconsent/ file and edit where needed.

Star History Chart