PHPackages                             the42coders/eu-cookie-consent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. the42coders/eu-cookie-consent

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

the42coders/eu-cookie-consent
=============================

To make your site compliant to the EU GDPR law you can use this package and customize it to your needs.

v1.0.5(3y ago)5939.4k↓34.1%15[2 PRs](https://github.com/42coders/eu-cookie-consent/pulls)MITPHPPHP &gt;7.1

Since Oct 28Pushed 1y ago5 watchersCompare

[ Source](https://github.com/42coders/eu-cookie-consent)[ Packagist](https://packagist.org/packages/the42coders/eu-cookie-consent)[ Docs](https://github.com/42coders/eu-cookie-consent)[ RSS](/packages/the42coders-eu-cookie-consent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (0)

eu-cookie-consent helps you to stay conform with the EU cookie law
==================================================================

[](#eu-cookie-consent-helps-you-to-stay-conform-with-the-eu-cookie-law)

[![Latest Version on Packagist](https://camo.githubusercontent.com/45d188524ae80e21b38c802fe1d126705d039bdaa1eff5a58b160497bc9cfdb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7468653432636f646572732f65752d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/the42coders/eu-cookie-consent)[![Build Status](https://camo.githubusercontent.com/d8707fc7fc02c057766d61ee014ce379d082f2eed6219bc7ad1ed6845da69854/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f3432636f646572732f65752d636f6f6b69652d636f6e73656e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/42coders/eu-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/7e9ead1ea7378976901bc6dbce5f6a8a502275609a8db35060fcacd71bc6ea15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7468653432636f646572732f65752d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/the42coders/eu-cookie-consent)

All sites owned by EU citizens or targeted towards EU citizens must comply with a crazy EU law. This law requires a dialog to be displayed to inform the users of your websites how cookies are being used. You can read more info on the legislation on [the site of the European Commission](http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm#section_2).

This package provides an easily configurable view to display the message. Also included is JavaScript code to set a cookie when a user agrees with the cookie policy. The package will not display the dialog when that cookie has been set.

[![PopupImage](./resources/img/cookie_gdpr.png)](./resources/img/cookie_gdpr.png)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require the42coders/eu-cookie-consent
```

Optionally you can publish the following Files

##### Config

[](#config)

This is recommended since you can configure all the consents you want to get from the visitor.

```
php artisan vendor:publish --provider="the42coders\EuCookieConsent\EuCookieConsentServiceProvider" --tag="config"
```

##### Views

[](#views)

If you want to customize the look and feel of the Package

```
php artisan vendor:publish --provider="the42coders\EuCookieConsent\EuCookieConsentServiceProvider" --tag="views"
```

##### Language files

[](#language-files)

This package comes with multilanguage support out of the box. You can translate it to the Languages you want. Or just change the default Text.

```
php artisan vendor:publish --provider="the42coders\EuCookieConsent\EuCookieConsentServiceProvider" --tag="lang"
```

Config
------

[](#config-1)

This is the heart of the Package you can define all the Cookies/Permissions you want to get form the User.

```
return [

    /*
     * Use this setting to enable the cookie consent dialog.
     */
    'enabled' => env('COOKIE_CONSENT_ENABLED', true),

    /*
     * The name of the cookie in which we store if the user
     * has agreed to accept the conditions.
     */
    'cookie_name' => 'laravel_eu_cookie_consent',

    /*
     * Set the cookie duration in minutes.  Default is 365 * 24 * 60 = 1 Year.
     */
    'cookie_lifetime' => 365 * 24 * 60,

    /*
     * Multilanguage support
     *
     * If enabled the title, description, the category keys and the cookie keys are defining the key from the translation files.
     */
    'multilanguage_support' => true,

    /*
     * Save Cookies Route
     */
    'route' => '/saveTheCookie',

    /*
     * Define the style of the Popup
     */
    'popup_style' => '',

    /*
     * Define classes the popup should use.
     */
    'popup_classes' => 'eu-popup',

    /*
     * If you want to have an Accept all Button for the users
     */
    'acceptAllButton' => 'true',

    /*
     * Cookies
     */
    'cookies' => [
        //Defines the translation Key for the saveButton
        'saveButton' => 'Save',
        //Optional: Defines the translation Key for the PopupTitle
        'title' => 'PopupTitle',
        //Optional: Defines the translation Key for the PopupDescription
        'description' => 'PopupDescription',
        //To make the popup easier to consume for the user you can organize your Cookies in categories.
        'categories' => [
            //The key defines the translation key in the translations for this category.
            'essential' => [
                //Optional: The description defines the key in the translations for the category description
                'description' => 'essential_description',
                //In this array you can define all the Cookies you want to request form the User
                'cookies' => [
                    //The key defines the key in the translations and is used to access the Cookie specific information
                    'session' => [
                        //Optional: you can set forced to make it impossible for the user to not accept this cookie.
                        'forced' => 'true',
                        //Optional: The description defines the key in the translations
                        //'description' => 'key in translation File'
                    ],
                    'xsrf-token' => [
                        'forced' => 'true',
                    ],
                ],
            ],
        ],
    ],

];
```

Usage
-----

[](#usage)

##### Popup

[](#popup)

To enable the Popup you can use the following Code in your blade Files (it returns html code).

```
{!! EuCookieConsent::getPopup() !!}
```

If you want to give the users the option to change the permissions just add another line

```
{!! EuCookieConsent::getUpdatePopup() !!}
```

This gives you the possibility to call the dialog with the given user settings by javascript.

Just call the following js function and the popup will appear.

```
update_popup()
```

##### Permission

[](#permission)

If you want to check if the user gave you a specific permission. You can just pass the key of the Cookie you defined in the config file.

```
EuCookieConsent::canIUse('key from the cookies config')
```

##### Scripts/Imports ...

[](#scriptsimports-)

Very often we want to play out a specific Script Tag ... only if the user allowed us. You can define the Scripts in the config of the cookie. If you use the key header for example you can render them from all of the cookies.

```
{!! EuCookieConsent::getHtml('header') !!}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Max Hutschenreiter](https://github.com/42coders)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~142 days

Recently: every ~177 days

Total

6

Last Release

1316d ago

PHP version history (2 changes)v1.0.0PHP ^7.1

v1.0.3PHP &gt;7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24477550?v=4)[42coders](/maintainers/42coders)[@42coders](https://github.com/42coders)

---

Top Contributors

[![Max-Hutschenreiter](https://avatars.githubusercontent.com/u/8393676?v=4)](https://github.com/Max-Hutschenreiter "Max-Hutschenreiter (17 commits)")[![tms1987](https://avatars.githubusercontent.com/u/77532530?v=4)](https://github.com/tms1987 "tms1987 (1 commits)")

---

Tags

42coderseu-cookie-consent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/the42coders-eu-cookie-consent/health.svg)

```
[![Health](https://phpackages.com/badges/the42coders-eu-cookie-consent/health.svg)](https://phpackages.com/packages/the42coders-eu-cookie-consent)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[the42coders/workflows

This Package allows you to automate your Laravel Application from your Backend.

2652.3k](/packages/the42coders-workflows)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
