PHPackages                             christopheraseidl/livewire-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. christopheraseidl/livewire-cookie-consent

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

christopheraseidl/livewire-cookie-consent
=========================================

Display a cookie consent notice and cookie policy in Laravel (Livewire + Alpine.js + Tailwind CSS).

v1.1.0(1y ago)363MITPHPPHP ^8.0

Since Jul 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/christopheraseidl/livewire-cookie-consent)[ Packagist](https://packagist.org/packages/christopheraseidl/livewire-cookie-consent)[ RSS](/packages/christopheraseidl-livewire-cookie-consent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Add a GDPR-compliant cookie notice to your Laravel project using Livewire
=========================================================================

[](#add-a-gdpr-compliant-cookie-notice-to-your-laravel-project-using-livewire)

This package provides an easy way to display a cookie consent notice along with a cookie policy that can be displayed in the default modal or anywhere else in your application. It requires Livewire 3 and Tailwind CSS.

All websites that wish to be used in Europe must comply with an EU law stipulating that users must be advised of — and must consent to — any tracking or analytics cookies. Functional cookies are optional. To be sure, you may want to consult the [European Commission guidelines](https://commission.europa.eu/resources-partners/europa-web-guide/design-content-and-development/privacy-security-and-legal-notices/cookies-and-similar-technologies_en).

When using this package, be sure to confirm that the policy text meets your requirements. You will probably want to edit it after publishing the views.

Finally, note that this package ships by default with English and Spanish translations.

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

[](#installation)

You can install the package via composer:

```
composer require christopheraseidl/livewire-cookie-consent
```

You should then run the installation command:

```
php artisan cookie-consent:install
```

This will:

1. publish the necessary assets;
2. set up `tailwind.config.js`, `vite.config.js`, and `app.css`;
3. and run `npm run build` to compile your project for production.

The package will automatically register its service provider.

If you are using an alternative asset bundler like Mix, you will need to make some manual adjustments to the installation and setup process.

If you publish the views, you should modify your `tailwind.config.js` file to exclude the defaults located in the `/vendor/christopheraseidl/livewire-cookie-consent` folder.

Configuration
-------------

[](#configuration)

You may publish the config file if you wish:

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

By default, the contents of this file are as follows:

```
return [
    'cookie_name'             => 'cas_laravel_cookie_consent',
    'cookies_to_delete'       => [],
    'consent_value'           => 'yes',
    'refuse_value'            => 'no',
    'enabled'                 => true,
    'consent_cookie_lifetime' => 60 * 24 * 365,
    'refuse_cookie_lifetime'  => 60 * 24 * 30,
    'available_locales'       => ['en', 'es'],
];
```

Usage
-----

[](#usage)

You have two options for using the modal that asks the user for consent:

#### Option 1. Including the Livewire component directly in a template:

[](#option-1-including-the-livewire-component-directly-in-a-template)

```
// Somewhere in your blade template
@livewire('cookie-consent')
```

#### Option 2. Adding the middleware to the kernel:

[](#option-2-adding-the-middleware-to-the-kernel)

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

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

    // ...
}
```

When the user allows cookies — by clicking `Yes.` — a `cas_laravel_cookie_consent` cookie will be set, and the dialog will be hidden until the cookie expires, by default with a lifetime of `60 * 24 * 365`.

You can check whether consent has been given with the provided service facade: `CookieConsent::consentGiven()`.

You can call a similar method to check whether consent has been refused: `CookieConsent::consentRefused()`.

Including the cookie policy component
-------------------------------------

[](#including-the-cookie-policy-component)

The modal provided by this package already includes the cookie policy component, which you can include anywhere in your application, like so:

```

```

You may customize this policy by publishing the views and editing the resulting component view file.

Should you wish to provide a policy in another language, first [set up your application to use your locale](https://laravel.com/docs/11.x/localization), then create a directory for your locale in `/resources/views/christopheraseidl/policy/`, then place a file there called `cookie-policy.blade.php`

Disabling the package
---------------------

[](#disabling-the-package)

To stop this package from displaying a modal or handling cookie consent, after publishing the configuration file, change `enabled` to `false`.

Deleting an array of cookies when consent is refused
----------------------------------------------------

[](#deleting-an-array-of-cookies-when-consent-is-refused)

If you want to delete cookies in your application when the user refuses consent, publish the config file and add their names to the `cookies_to_delete` array. For example:

```
//config/cookie-consent.php

return [
    // ...
    'cookies_to_delete' => ['delete_me', 'delete_me_also'],
];
```

Customizing translations
------------------------

[](#customizing-translations)

You may publish the translations to `resources/lang/christopheraseidl/cookie-consent` with this command:

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

Customizing views
-----------------

[](#customizing-views)

You may publish the views to `resources/views/christopheraseidl/cookie-consent` with this command:

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

Uninstalling
------------

[](#uninstalling)

Before running `composer remove christopheraseidl/livewire-cookie-consent`, you should run the following command to clean up after this package:

```
php artisan cookie-consent:uninstall
```

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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 ~16 days

Total

2

Last Release

645d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/639d641f14096c8c9e5e0e990b06414f5ed5f6ea4d13b6e103aae2405ce870fc?d=identicon)[christopheraseidl](/maintainers/christopheraseidl)

---

Top Contributors

[![christopheraseidl](https://avatars.githubusercontent.com/u/73406146?v=4)](https://github.com/christopheraseidl "christopheraseidl (2 commits)")

---

Tags

alpinejslaravellivewiretailwindcss

### Embed Badge

![Health badge](/badges/christopheraseidl-livewire-cookie-consent/health.svg)

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

###  Alternatives

[livewire/flux

The official UI component library for Livewire.

9385.0M85](/packages/livewire-flux)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[jantinnerezo/livewire-alert

This package provides a simple alert utilities for your livewire components.

8041.2M20](/packages/jantinnerezo-livewire-alert)[leandrocfe/filament-apex-charts

Apex Charts integration for Filament PHP.

4861.2M8](/packages/leandrocfe-filament-apex-charts)[spatie/laravel-livewire-wizard

Build wizards using Livewire

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

A dashboard for Laravel

568156.1k94](/packages/spatie-laravel-dashboard)

PHPackages © 2026

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