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

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

statikbe/laravel-cookie-consent
===============================

Cookie consent modal for EU

1.12.0(3mo ago)219426.2k↓31.2%27[1 issues](https://github.com/statikbe/laravel-cookie-consent/issues)MITPHPPHP ^8.0CI failing

Since Feb 3Pushed 1w ago7 watchersCompare

[ Source](https://github.com/statikbe/laravel-cookie-consent)[ Packagist](https://packagist.org/packages/statikbe/laravel-cookie-consent)[ Docs](https://github.com/statikbe/laravel-cookie-consent)[ RSS](/packages/statikbe-laravel-cookie-consent/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (70)Used By (0)

[![Card of Laravel Cookie consent](docs/img/card.png)](docs/img/card.png)

Laravel cookie consent modal
============================

[](#laravel-cookie-consent-modal)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1eb0a368df213765a20936d36b34b1a1bcc00e987298904470f429e5a7006933/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746174696b62652f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/statikbe/laravel-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/2b4b69ce2cf77631a81206971a3432037fcd842376d178b45243ef2ce15600d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746174696b62652f6c61726176656c2d636f6f6b69652d636f6e73656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/statikbe/laravel-cookie-consent)

[![Modal cookie consent](docs/img/modal.png?raw=true "Modal for Cookie consent")](docs/img/modal.png?raw=true)

[![Preferences Modal](docs/img/preferences.png?raw=true "Preferences for cookies")](docs/img/preferences.png?raw=true)

Cookie banner and preferences modal for Laravel. Visitors choose which cookie categories they accept; Google Tag Manager reads the resulting cookie to decide which tags fire. Based on [spatie/laravel-cookie-consent](https://github.com/spatie/laravel-cookie-consent) with added per-category consent.

Requirements
------------

[](#requirements)

LaravelPHP10–138.0+Upgrading
---------

[](#upgrading)

See [upgrading.md](upgrading.md).

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Filament Integration](#filament-integration)
- [Customisation](#customisation)
- [Google Tag Manager](#google-tag-manager)
- [Security](#security)
- [License](#license)

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

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

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

The package registers itself automatically.

### 2. Register the middleware

[](#2-register-the-middleware)

**Laravel 11 and later** — in `bootstrap/app.php`:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ]);
})
```

Or as a named alias:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'cookie-consent' => \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ]);
})
```

**Laravel 10 and earlier** — in `app/Http/Kernel.php`:

```
protected $middlewareGroups = [
    'web' => [
        // ...
        \Statikbe\CookieConsent\CookieConsentMiddleware::class,
    ],
];
```

Or as a named middleware applied to specific routes:

```
// app/Http/Kernel.php
protected $routeMiddleware = [
    'cookie-consent' => \Statikbe\CookieConsent\CookieConsentMiddleware::class,
];

// routes/web.php
Route::middleware('cookie-consent')->group(function () {
    // ...
});
```

The middleware injects the cookie consent snippet into every HTML response before the closing `` tag.

### 3. Publish the assets

[](#3-publish-the-assets)

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-public"
```

### 4. Include the stylesheet (default theme only)

[](#4-include-the-stylesheet-default-theme-only)

Add this to your base template. Skip this step if you are using the Filament theme — see [Filament Integration](#filament-integration).

```

```

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

[](#configuration)

Publish the config file:

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

`config/cookie-consent.php`:

```
return [
    /*
     * Theme for the cookie consent popup.
     * Options: 'default', 'filament'
     */
    'theme' => 'default',

    /*
     * Filament render hook used to register the cookie settings nav item.
     * Set to null to disable the nav item entirely.
     * See: Filament Integration > Nav item
     */
    'filament-nav-item-render-hook' => \Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER,

    /*
     * Name of the cookie written to the browser.
     * If you change this, update the GTM variable name to match.
     */
    'cookie_key' => '__cookie_consent',

    /*
     * Values written to the cookie for each consent choice.
     *
     *   analytics only  => '2'
     *   marketing only  => '3'
     *   both accepted   => 'true'
     *   none accepted   => 'false'
     *
     * GTM reads this value with regex triggers to decide which tags fire.
     * If you change these values, update your GTM triggers to match.
     */
    'cookie_value_analytics' => '2',
    'cookie_value_marketing' => '3',
    'cookie_value_both' => 'true',
    'cookie_value_none' => 'false',

    'cookie_expiration_days' => '365',

    /*
     * GTM custom event fired after the visitor saves their preferences.
     */
    'gtm_event' => 'cookie_refresh',

    /*
     * Relative paths where the cookie banner is suppressed.
     * Accepts wildcards via Str::is() — e.g. '/api/*', '/en/cookie-policy'.
     */
    'ignored_paths' => [],

    /*
     * Set to true to suppress the banner on 4xx/5xx error pages.
     */
    'skip_on_error_responses' => false,

    /*
     * Mark the consent cookie as Secure (HTTPS only).
     * Reads from the COOKIE_CONSENT_SECURE env variable.
     */
    'cookie_secure' => env('COOKIE_CONSENT_SECURE', false),

    /*
     * Cookie policy page URLs shown in the banner.
     * Read from env — add only the locales your site supports.
     */
    'policy_url_en' => env('COOKIE_POLICY_URL_EN', null),
    'policy_url_fr' => env('COOKIE_POLICY_URL_FR', null),
    'policy_url_nl' => env('COOKIE_POLICY_URL_NL', null),
];
```

### Hiding the banner on specific pages

[](#hiding-the-banner-on-specific-pages)

```
'ignored_paths' => ['/en/cookie-policy', '/api/documentation*'],
```

Wildcards use Laravel's [`Str::is()`](https://laravel.com/docs/helpers#method-str-is) matching.

### Hiding the banner on error pages

[](#hiding-the-banner-on-error-pages)

```
'skip_on_error_responses' => true,
```

Filament Integration
--------------------

[](#filament-integration)

If your project uses [Filament](https://filamentphp.com), you can render the cookie banner using Filament components instead of the default styled theme.

### 1. Enable the Filament theme

[](#1-enable-the-filament-theme)

```
// config/cookie-consent.php
'theme' => 'filament',
```

This will render the cookie popup using Filament components:

[![screenshot of filament theme](./assets/screenshot-filament.png)](./assets/screenshot-filament.png)

The default theme looks like this for comparison:

[![screenshot of default theme](./assets/screenshot-default.png)](./assets/screenshot-default.png)

### 2. Configure Tailwind to scan the package views

[](#2-configure-tailwind-to-scan-the-package-views)

**Tailwind v4** — in your main CSS file:

```
@source 'vendor/statikbe/laravel-cookie-consent/resources/**/*.blade.php';
```

**Tailwind v3** — in `tailwind.config.js`:

```
export default {
    content: [
        'vendor/statikbe/laravel-cookie-consent/resources/**/*.blade.php',
    ]
}
```

### 3. Filament styles outside the panel

[](#3-filament-styles-outside-the-panel)

If you display the cookie banner on pages that are not inside a Filament panel, include Filament's CSS and JS in those page templates.

### 4. Cookie settings nav item

[](#4-cookie-settings-nav-item)

When the Filament theme is active, the package registers a "Cookie settings" link in the Filament user menu. The position is controlled by `filament-nav-item-render-hook`, which defaults to after the profile menu item.

To change the position, set a different render hook value:

```
'filament-nav-item-render-hook' => \Filament\View\PanelsRenderHook::SIDEBAR_NAV_END,
```

To remove the nav item entirely:

```
'filament-nav-item-render-hook' => null,
```

Customisation
-------------

[](#customisation)

### Translations

[](#translations)

Publish the language files:

```
php artisan vendor:publish --provider="Statikbe\CookieConsent\CookieConsentServiceProvider" --tag="cookie-lang"
```

Files land in `lang/vendor/cookie-consent/{locale}/texts.php`. To add a new locale, copy the `en` directory to the target locale and translate the strings.

### Views

[](#views)

Publish the view files:

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

Files land in `resources/views/vendor/cookie-consent`.

To let visitors re-open the preferences modal (e.g. from your footer next to the cookie policy link):

```

    @lang('cookie-consent::texts.alert_settings')

```

Google Tag Manager
------------------

[](#google-tag-manager)

Set up GTM to read the consent cookie and control which tags fire. Full setup instructions: [docs/google-tag-manager.md](docs/google-tag-manager.md).

Security
--------

[](#security)

If you discover a security issue, 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

66

—

FairBetter than 99% of packages

Maintenance90

Actively maintained with recent releases

Popularity54

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~28 days

Total

52

Last Release

107d ago

PHP version history (2 changes)1.2.9PHP ^7.0|^8.0

1.5.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1250437446b84017407f7f1900194b1e1c93fcf34b332ba382fb77f69b251cb6?d=identicon)[statikbe](/maintainers/statikbe)

---

Top Contributors

[![kristofser](https://avatars.githubusercontent.com/u/5928907?v=4)](https://github.com/kristofser "kristofser (87 commits)")[![sevbesau](https://avatars.githubusercontent.com/u/16073039?v=4)](https://github.com/sevbesau "sevbesau (44 commits)")[![stijnelskens](https://avatars.githubusercontent.com/u/12715277?v=4)](https://github.com/stijnelskens "stijnelskens (32 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (29 commits)")[![dduupp](https://avatars.githubusercontent.com/u/10728938?v=4)](https://github.com/dduupp "dduupp (19 commits)")[![carolineboeykens](https://avatars.githubusercontent.com/u/42932673?v=4)](https://github.com/carolineboeykens "carolineboeykens (13 commits)")[![sten](https://avatars.githubusercontent.com/u/180665?v=4)](https://github.com/sten "sten (4 commits)")[![patimio66](https://avatars.githubusercontent.com/u/78798236?v=4)](https://github.com/patimio66 "patimio66 (3 commits)")[![javiersanzsanchez](https://avatars.githubusercontent.com/u/16131716?v=4)](https://github.com/javiersanzsanchez "javiersanzsanchez (1 commits)")[![borjajimnz](https://avatars.githubusercontent.com/u/5682426?v=4)](https://github.com/borjajimnz "borjajimnz (1 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (1 commits)")[![janhenckens](https://avatars.githubusercontent.com/u/755428?v=4)](https://github.com/janhenckens "janhenckens (1 commits)")[![AurelDemiri](https://avatars.githubusercontent.com/u/30560661?v=4)](https://github.com/AurelDemiri "AurelDemiri (1 commits)")[![Kobo-one](https://avatars.githubusercontent.com/u/11278919?v=4)](https://github.com/Kobo-one "Kobo-one (1 commits)")[![Mejans](https://avatars.githubusercontent.com/u/61360811?v=4)](https://github.com/Mejans "Mejans (1 commits)")

---

Tags

laravelcookieGoogle Tag Managerfilamentgdprprivacyconsentcookie-banner

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[devrabiul/laravel-cookie-consent

A GDPR-compliant cookie consent solution for Laravel applications with fully customizable cookie banners, granular consent control, and enterprise-grade compliance features.

18355.4k1](/packages/devrabiul-laravel-cookie-consent)[martin-schenk/laravel-cookie-consent

GDPR-compliant cookie consent system with minimal dependencies for Laravel 11 and 12

112.3k](/packages/martin-schenk-laravel-cookie-consent)

PHPackages © 2026

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