Giter Club home page Giter Club logo

laravel-cookie-consent's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


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:

  • Receive users’ consent before you use any cookies except strictly necessary cookies.
  • Provide accurate and specific information about the data each cookie tracks and its purpose in plain language before consent is received.
  • Document and store consent received from users.
  • Allow users to access your service even if they refuse to allow the use of certain cookies.
  • Make it as easy for users to withdraw their consent as it was for them to give their consent in the first place.

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

  • Define the user cookie consent's duration.
  • Configuration key : "cookie_lifetime".
  • Default value : 1 year.
  • Unit : minutes.

Cookie name

  • Define the user cookie consent's cookie name.
  • Configuration key : "cookie_name".
  • Default value : "cookie-consent".
  • Unit : string.

Cookies

  • Define the cookies the user has to consent.
  • Configuration key : "cookies".
  • Default value : random cookies configurations, change it with what you need.
  • Unit : array.
  • Each cookie configuration contains some keys :
    • key : key of the cookie, must be unique.
    • title : translation key for the title.
    • description : translation key for the description.
    • group : a group key (only used with a group display, see "Preferences display mode").
    • locked : if set to "true", this cookie is only displayed for information, it is not part of the validation process.

Groups

  • Define the cookie groups the user has to consent (only used with a group display, see "Preferences display mode").
  • Configuration key : "cookies-group".
  • Default value : random cookies groups configurations, change it with what you need.
  • Unit : array.
  • Each cookie group configuration contains some keys :
    • key : key of the group, must be unique and not the same of a cookie's key.
    • title : translation key for the title.
    • description : translation key for the description.
    • locked : if set to "true", this group is only displayed for information, it is not part of the validation process.

Custom class

  • Define one, or many class to customize the popup design.
  • Configuration key : "custom-class".
  • Default value : empty.
  • Unit : string.

IHM ids

  • Used to override the ids of the popup if already exists in your website.
  • Configuration key : "ihmIds".
  • Default value : default ids.
  • Unit : array.

Position

  • Set the position of the popup. Can be set to "top" or "bottom".
  • Configuration key : "position".
  • Default value : "bottom".
  • Unit : string.

Preferences display mode

  • Set the preferences popup display mode. Can be set to "list" or "group".
  • Configuration key : "preferences-display-mode".
  • Default value : "list".
  • Unit : string.

List display Cookie consent popup not validated preferences_list_display

Group display Cookie consent popup not validated preferences_group_display

Preferences validation mode

  • Set the preferences popup validation mode (only used with a group display, see "Preferences display mode"). Can be set to "item" or "group".
  • Configuration key : "preferences-validation-mode".
  • Default value : "group".
  • Unit : string.

Group validation Cookie consent popup not validated preferences_group_validation

Item validation Cookie consent popup not validated preferences_item_validation

Routes

  • Used to override the routes of the package if already exists in your website.
  • Configuration key : "routes".
  • Default value : default routes.
  • Unit : array.

Update preferences button ids

  • One or many ids of your present in your website to reopen the validation popup.
  • Configuration key : "updatePreferencesButtonIds".
  • Default value : "update-preferences".
  • Unit : string or array.

Contributing

To contribute you can :

  • Open an issue
  • Create a Pull Request with your modifications and corresponding unit tests.
    • Fork the Project
    • Create your Feature Branch (git checkout -b feature/myFeature)
    • Commit your Changes (git commit -m 'message')
    • Push to the Branch (git push origin feature/myFeature)
    • Open a Pull Request

License

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

Contact

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

laravel-cookie-consent's People

Contributors

pierre-adrien avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.