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

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

justijndepover/laravel-cookie-consent
=====================================

Make your Laravel application comply with the EU cookie law.

0.6.0(2y ago)102.2k[2 issues](https://github.com/justijndepover/laravel-cookie-consent/issues)MITPHP

Since Nov 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/justijndepover/laravel-cookie-consent)[ Packagist](https://packagist.org/packages/justijndepover/laravel-cookie-consent)[ RSS](/packages/justijndepover-laravel-cookie-consent/feed)WikiDiscussions master Synced 3d ago

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

Laravel Cookie Consent
======================

[](#laravel-cookie-consent)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b31cfafd49663087c0fd41641063cd19b18e5c536f9424a2cbf3645e440e51f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a757374696a6e6465706f7665722f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/justijndepover/laravel-cookie-consent)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/3f55e267961c68904a4f8943900e6c03beb9669b5f507bec43952f4a3baedb71/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a757374696a6e6465706f7665722f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/justijndepover/laravel-cookie-consent)

Make your Laravel application comply with the EU cookie law.

Caution
-------

[](#caution)

This application is still in development and could implement breaking changes. Please use at your own risk.

Explanation
-----------

[](#explanation)

This package stores all cookies in the database. Each cookie can be enabled / disabled by the user of your Laravel application. Accepting the cookie banner will load all cookies within the same request and execute them. (This is great for page trackers)

A cookie bar will be added to your application with 2 options:

- Accept: All cookie scripts will be loaded. (through javascript in the same request and all concurrent requests)
- Decline: Not a single cookie script will be loaded.

[![dialog](https://raw.githubusercontent.com/justijndepover/laravel-cookie-consent/master/docs/screenshot.png)](https://raw.githubusercontent.com/justijndepover/laravel-cookie-consent/master/docs/screenshot.png)

After confirming / denying the cookie bar, the user still has the option to change his preferences.

The cookie value will always contain a encrypted list with the cookie id's that are turned of. Therefore, adding in a new cookie, has to be disabled by the end user again.

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

[](#installation)

You can install the package with composer

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

After installation you have to publish the migration, if you don't have a cookies table / model

```
php artisan vendor:publish --tag="laravel-cookie-consent-migration"
php artisan migrate
```

And optionally publish the configuration file

```
php artisan vendor:publish --tag="laravel-cookie-consent-config"
```

### model setup

[](#model-setup)

Your `Cookie` class should also use the `InteractsWithCookies` trait.

```
use Justijndepover\CookieConsent\Concerns\InteractsWithCookies; // add this line

class Cookie
{
    use InteractsWithCookies; // add this line
}
```

configuration
-------------

[](#configuration)

This is the config file

```
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_cookie_consent',

    /*
     * Set the cookie duration in days.  Default is 365 * 20.
     */
    'cookie_lifetime' => 365 * 20,

    /*
     * Set the model class that represents the cookies table
     * Make sure your Cookie model implements the InteractsWithCookies trait
     */
    'cookie_class' => \App\Models\Cookie::class,

    /*
     * These middleware will get attached onto each Laravel Cookie Consent route, giving you
     * the chance to add your own middleware to this list or change any of
     * the existing middleware. Or, you can simply stick with this list.
     */
    'middleware' => ['web'],

];
```

Usage
-----

[](#usage)

include the following in your app layout to render the cookie bar:

```
// before the closing body tag
@include('cookie-consent::bar', ['text' => 'This website makes use of cookies', 'accept' => 'Accept', 'cancel' => 'Refuse'])
```

toggle cookies
--------------

[](#toggle-cookies)

You as the developer should provide a page where each cookie is rendered in a table list. To let the end user toggle each cookie, make a post request as followed:

```
@foreach ($cookies as $cookie)

        @csrf

        @if ($cookie->isEnabled())
            Active
        @else
            Not active
        @endif

@endforeach
```

The endpoint `cookies.toggle` is setup by the package and will toggle whether or not the cookie should be rendered.

Styling
-------

[](#styling)

The package comes with a default tailwind styling. If you want to customize the layout, you should publish the view

```
php artisan vendor:publish --tag="laravel-cookie-consent-view"
```

Now you can edit the layout yourself.

The script loaded by the plugin expects the buttons to have a data attribute as followed:

```
Decline
Accept
```

Security
--------

[](#security)

If you find any security related issues, please open an issue or contact me directly at [justijndepover@gmail.com](justijndepover@gmail.com).

Contribution
------------

[](#contribution)

If you wish to make any changes or improvements to the package, feel free to make a pull request.

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~212 days

Recently: every ~229 days

Total

6

Last Release

941d ago

### Community

Maintainers

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

---

Top Contributors

[![justijndepover](https://avatars.githubusercontent.com/u/9008623?v=4)](https://github.com/justijndepover "justijndepover (21 commits)")

---

Tags

cookieshacktoberfestlaravelphp

### Embed Badge

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

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

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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