w3designweb/laravel-cookie-consent

This package for Laravel allows you to manage user cookies consents in compliance with privacy regulations.

v1.2.0 2023-10-24 07:52 UTC

This package is auto-updated.

Last update: 2024-04-24 08:48:39 UTC


README

Latest Version on Packagist Software License Scrutinizer Code Quality Quality Score Build Total Downloads

With this package it will be easy for you to declare all the cookies used on your website, asking for consent through a banner that will be activated automatically through a Laravel Middleware.

Each user can accept or not the different types of cookies, thus deciding whether to enable the related functions, and also can change the consents given over time.

Installation

Require the package with Composer:

composer require w3designweb/laravel-cookie-consent

Laravel

For Laravel 5.4 and lower, add the service provider to config/app.php:

W3designweb\LaravelCookieConsent\LaravelCookieConsentServiceProvider::class,

Lumen

Add the service provider to bootstrap/app.php:

$app->register(W3designweb\LaravelCookieConsent\LaravelCookieConsentServiceProvider::class);

Configuration

Then, add this configuration to your .env file to enable the cookie banner. By default the value is set to "true", but it will be sufficient to indicate "false" to not show the cookie banner.

COOKIE_CONSENT_ENABLED=true
COOKIE_CONSENT_NAME=your_cookie_consent_name

After that, add the middleware in the group of your choice, inside the App/Http/Kernel.php file, per example:

'web' => [
    ...
    W3designweb\LaravelCookieConsent\Http\Middleware\LaravelCookieConsent::class,
    ...
],

Publish the package files to manage your cookies list in the config file, the blade template on the view file and the assets in CSS and JS file:

php artisan vendor:publish --provider="W3designweb\LaravelCookieConsent\LaravelCookieConsentServiceProvider"