Pierre-Adrien / laravel-cookie-consent

This package provides a fully configurable cookie-consent popup for a Laravel project.
MIT License
7 stars 3 forks source link

Contributors Forks Stargazers Issues MIT License LinkedIn


Laravel Cookie-Consent

This package provides a fully customizable cookie-consent popup for a Laravel project.

Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Installation
  3. Usage
  4. Configuration
  5. Contributing
  6. License
  7. Contact

About The Project

Passed in the 2002 and amended in 2009, the ePrivacy Directive (EPD) has become known as the “cookie law” since its most notable effect was the proliferation of cookie consent pop-ups after it was passed. It supplements (and in some cases, overrides) the GDPR, addressing crucial aspects about the confidentiality of electronic communications and the tracking of Internet users more broadly.

To comply with the regulations governing cookies under the GDPR and the ePrivacy Directive you must:

This package provides a fully configurable cookie-consent popup for a Laravel project.

Here is a standard use of it. All possibilities are described in this documentation.

Validation popup home Cookie consent popup not validated home

Validation popup preferences (not validated) Cookie consent popup not validated preferences

Validation popup preferences (validated) Cookie consent popup validated

Installation

  1. The package can be installed via composer :

    composer require pierre-adrien/laravel-cookie-consent
  2. Publish files :

Configuration : allow you to modify the configuration of the displayed popup.

   php artisan vendor:publish --provider="Pam\CookieConsent\CookieConsentServiceProvider" --tag="config"

Assets : REQUIRED to proper execution.

   php artisan vendor:publish --provider="Pam\CookieConsent\CookieConsentServiceProvider" --tag="assets"

Languages : allow you to set the translations.

   php artisan vendor:publish --provider="Pam\CookieConsent\CookieConsentServiceProvider" --tag="lang"

Views : allow you to modify the displayed popup.

   php artisan vendor:publish --provider="Pam\CookieConsent\CookieConsentServiceProvider" --tag="views"

Usage

Add the cookie-consent popup at the end of your "body" tag :

  {{ CookieConsent::getCookieConsentPopup() }}

Add content depending on a consent for a cookie key or a group key :

  @if(CookieConsent::isAllowed('key'))
    {{-- Do some stuff --}}
  @endif

You can also use the isAllowed method in your php code with the CookieConsent facade.

Configuration

All the configurations of the published "config/cookie-consent.php" file are listed and explained here.

Cookie lifetime

Cookie name

Cookies

Groups

Custom class

IHM ids

Position

Preferences display mode

List display Cookie consent popup not validated preferences_list_display

Group display Cookie consent popup not validated preferences_group_display

Preferences validation mode

Group validation Cookie consent popup not validated preferences_group_validation

Item validation Cookie consent popup not validated preferences_item_validation

Routes

Update preferences button ids

Contributing

To contribute you can :

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/Pierre-Adrien/laravel-cookie-consent