PHPackages                             aonodevs/laravel-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. aonodevs/laravel-cookie-consent

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

aonodevs/laravel-cookie-consent
===============================

Make your Laravel app comply with the crazy EU cookie law

5.0.0(3mo ago)02.7kMITPHPPHP ^8.3

Since Jun 27Pushed 3mo agoCompare

[ Source](https://github.com/AonoDevs/laravel-cookie-consent)[ Packagist](https://packagist.org/packages/aonodevs/laravel-cookie-consent)[ Docs](https://github.com/aonodevs/laravel-cookie-consent)[ RSS](/packages/aonodevs-laravel-cookie-consent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (61)Used By (0)

Make your Laravel app comply with the refuse/accept cookie law
==============================================================

[](#make-your-laravel-app-comply-with-the-refuseaccept-cookie-law)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f249ec22cee782bad6f3aa34d549fd3058c4d564350a2e880b8970e331b58f1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726574696e656e732f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/retinens/laravel-cookie-consent)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Workflow Status](https://camo.githubusercontent.com/b408f9146e274049dcb898b80bb912f1f414b300edea94d8cde790e20137c868/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f726574696e656e732f6c61726176656c2d636f6f6b69652d636f6e73656e742f72756e2d74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/b408f9146e274049dcb898b80bb912f1f414b300edea94d8cde790e20137c868/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f726574696e656e732f6c61726176656c2d636f6f6b69652d636f6e73656e742f72756e2d74657374733f6c6162656c3d7465737473)[![Total Downloads](https://camo.githubusercontent.com/eb08fc4b528743d8f4a833f9e79161e45b095dd69027c48c50094aef516a06fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726574696e656e732f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/retinens/laravel-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).

The users should be presented the option to agree or disagree with the optional cookies.

This package is based on the spatie/laravel-cookie-consent package by the good folks at Spatie.

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

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

[](#installation)

You can install the package via composer:

```
composer require retinens/laravel-cookie-consent
```

The package will automatically register itself.

Optionally you can publish the config-file:

```
php artisan vendor:publish --provider="Retinens\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-config"
```

This is the contents of the published config-file:

```
return [

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

    /*
     * Use this setting to add a refuse button on the dialog.
    */
    'refuse_enabled' => env('COOKIE_CONSENT_REFUSE_ENABLED', false),

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

    /*
     * Set the cookie duration in days.  Default is 365 * 1.
     */
    'cookie_lifetime' => 365 * 1,
];
```

Usage
-----

[](#usage)

To display the dialog all you have to do is include this view in your template:

```
//in your blade template
@include('cookie-consent::index')
```

This will render the following dialog that, when styled, will look very much like this one.

[![dialog](https://camo.githubusercontent.com/7e1c9f667cc78755fe8b8c29be20397bcff7297a6b986a78b563e8686d299a8b/68747470733a2f2f726574696e656e732e6769746875622e696f2f6c61726176656c2d636f6f6b69652d636f6e73656e742f696d616765732f6469616c6f672e706e67)](https://camo.githubusercontent.com/7e1c9f667cc78755fe8b8c29be20397bcff7297a6b986a78b563e8686d299a8b/68747470733a2f2f726574696e656e732e6769746875622e696f2f6c61726176656c2d636f6f6b69652d636f6e73656e742f696d616765732f6469616c6f672e706e67)

The default styling provided by this package uses TailwindCSS v2 to provide a floating banner at the bottom of the page.

When the user clicks "Allow cookies" a `laravel_cookie_consent` cookie will be set and the dialog will be removed from the DOM. On the next request, Laravel will notice that the `laravel_cookie_consent` has been set and will not display the dialog again

Refuse button
-------------

[](#refuse-button)

If you want to add a refuse button to the dialog, you can enable the option in the config file. When the user clicks on "Refuse non-essential cookies" a `laravel_cookie_consent` cookie will be set with the value of `0`.

Customising the dialog texts
----------------------------

[](#customising-the-dialog-texts)

If you want to modify the text shown in the dialog you can publish the lang-files with this command:

```
php artisan vendor:publish --provider="Retinens\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-translations"
```

This will publish this file to `resources/lang/vendor/cookie-consent/en/texts.php`.

```
return [
    'message' => 'Please be informed that this site uses cookies.',
    'agree' => 'Allow cookies',
    'refuse' => 'Refuse non-essential cookies',
];
```

If you want to translate the values to, for example, French, just copy that file over to `resources/lang/vendor/cookie-consent/fr/texts.php` and fill in the French translations.

### Customising the dialog contents

[](#customising-the-dialog-contents)

If you need full control over the contents of the dialog. You can publish the views of the package:

```
php artisan vendor:publish --provider="Retinens\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-views"
```

This will copy the `index` and `dialogContents` view files over to `resources/views/vendor/cookie-consent`. You probably only want to modify the `dialogContents` view. If you need to modify the JavaScript code of this package you can do so in the `index` view file.

Using the middleware
--------------------

[](#using-the-middleware)

Instead of including `cookie-consent::index` in your view you could opt to add the `Retinens\CookieConsent\CookieConsentMiddleware` to your kernel:

```
// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \Retinens\CookieConsent\CookieConsentMiddleware::class,
    ];

    // ...
}
```

This will automatically add `cookie-consent::index` to the content of your response right before the closing body tag.

Helper
------

[](#helper)

In your code you can use the facade to get the info if the user has accepted or not the non-essential cookies.

```
CookieConsent::hasConsented();
CookieConsent::hasRefused();
```

That way you can (or not) add cookies for the user, or add scripts into the header.

Notice
------

[](#notice)

The legislation is pretty very vague on how to display the warning, which texts are necessary, and what options you need to provide. This package will go a long way towards compliance, but if you want to be 100% sure that your website is ok, you should consult a legal expert.

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
composer test
```

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.

License
-------

[](#license)

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

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity19

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 62.9% 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 ~59 days

Recently: every ~419 days

Total

60

Last Release

116d ago

Major Versions

0.0.1 → 1.0.02016-06-28

v1.x-dev → 2.0.02017-08-30

2.12.13 → 3.0.02021-03-26

3.1.1 → 4.0.02021-06-15

4.1.2 → 5.0.02026-01-15

PHP version history (8 changes)0.0.1PHP ^7.0

1.0.0PHP ^5.5|^7.0

1.3.0PHP ^5.6|^7.0

2.6.3PHP ^7.1

2.7.0PHP ^7.2

2.12.10PHP ^7.3|^8.0

3.0.0PHP ^8.0

5.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9a2ced2979327527e387f4e2581577b102cb6b891d8d6f2d53e9ddc3da31824?d=identicon)[aonoagency](/maintainers/aonoagency)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (124 commits)")[![WhereIsLucas](https://avatars.githubusercontent.com/u/25830895?v=4)](https://github.com/WhereIsLucas "WhereIsLucas (14 commits)")[![JeremyMarchand](https://avatars.githubusercontent.com/u/50629849?v=4)](https://github.com/JeremyMarchand "JeremyMarchand (11 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (7 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (4 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (3 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (3 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (3 commits)")[![willemvb](https://avatars.githubusercontent.com/u/1336390?v=4)](https://github.com/willemvb "willemvb (3 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (2 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (2 commits)")[![Roriwars](https://avatars.githubusercontent.com/u/46683598?v=4)](https://github.com/Roriwars "Roriwars (2 commits)")[![ruibeard](https://avatars.githubusercontent.com/u/8027649?v=4)](https://github.com/ruibeard "ruibeard (1 commits)")[![SabatinoMasala](https://avatars.githubusercontent.com/u/2678345?v=4)](https://github.com/SabatinoMasala "SabatinoMasala (1 commits)")[![sarperkaya](https://avatars.githubusercontent.com/u/1291111?v=4)](https://github.com/sarperkaya "sarperkaya (1 commits)")[![afraca](https://avatars.githubusercontent.com/u/244807?v=4)](https://github.com/afraca "afraca (1 commits)")[![semyonchetvertnyh](https://avatars.githubusercontent.com/u/2598761?v=4)](https://github.com/semyonchetvertnyh "semyonchetvertnyh (1 commits)")[![shuvroroy](https://avatars.githubusercontent.com/u/21066418?v=4)](https://github.com/shuvroroy "shuvroroy (1 commits)")[![telkins](https://avatars.githubusercontent.com/u/53731?v=4)](https://github.com/telkins "telkins (1 commits)")

---

Tags

laravelcookiecookie-consenteulawcomplyrefuseaonodevs

### Embed Badge

![Health badge](/badges/aonodevs-laravel-cookie-consent/health.svg)

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

###  Alternatives

[spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

1.5k4.7M20](/packages/spatie-laravel-cookie-consent)[retinens/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

354.5k](/packages/retinens-laravel-cookie-consent)[livewire/flux

The official UI component library for Livewire.

9385.0M86](/packages/livewire-flux)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)

PHPackages © 2026

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