PHPackages                             devrabiul/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. [Security](/categories/security)
4. /
5. devrabiul/laravel-cookie-consent

ActiveLibrary[Security](/categories/security)

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.

v2.1(2mo ago)17633.8k—6.6%15[3 PRs](https://github.com/devrabiul/laravel-cookie-consent/pulls)1MITPHP

Since Apr 5Pushed 2mo ago3 watchersCompare

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

READMEChangelog (6)DependenciesVersions (7)Used By (1)

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

[](#laravel-cookie-consent)

A GDPR-compliant solution offering enterprise-grade compliance with fully customizable cookie banners for Laravel applications. Simplifies regulatory requirements while maintaining excellent user experience and complete customization capabilities.

[![Latest Stable Version](https://camo.githubusercontent.com/9e1165340731cb6d9a112fcfbe0d9107d4bb2b277575ae037069f1dee8d164af/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e742f762f737461626c65)](https://packagist.org/packages/devrabiul/laravel-cookie-consent)[![Total Downloads](https://camo.githubusercontent.com/b9309acdf25e1bf842a22ff1930b7c141c9872503b9016d493ab761ec7b15ead/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e742f646f776e6c6f616473)](https://packagist.org/packages/devrabiul/laravel-cookie-consent)[![Monthly Downloads](https://camo.githubusercontent.com/2032c8b52c6cfd3f53dc9cfc4c5f53dc19e43bb2cee51643288765e4e6ca9fc3/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e742f642f6d6f6e74686c79)](https://packagist.org/packages/devrabiul/laravel-cookie-consent)[![GitHub license](https://camo.githubusercontent.com/fe5a2d6c9e619a644050cd67ff619bc54a05ff081490306223d282d223ad7015/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e74)](https://camo.githubusercontent.com/fe5a2d6c9e619a644050cd67ff619bc54a05ff081490306223d282d223ad7015/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e74)[![Buy us a tree](https://camo.githubusercontent.com/130148911f548b001b2ac68a32c0a06559977ca60ada3bf480c72ae4ea093175/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e)](https://plant.treeware.earth/devrabiul/laravel-cookie-consent)[![GitHub Repo stars](https://camo.githubusercontent.com/81b1645bc1ca7a0d0f6883a20518d82d70cc3babcb9457e4d3bc83bb2bd280a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e743f7374796c653d736f6369616c)](https://camo.githubusercontent.com/81b1645bc1ca7a0d0f6883a20518d82d70cc3babcb9457e4d3bc83bb2bd280a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e743f7374796c653d736f6369616c)

Features
--------

[](#features)

- 🔥 **One-Click Implementation** – Simple installation via Composer with auto-loaded assets
- ⚡ **Zero Performance Impact** – Lightweight with lazy-loaded components
- 🌍 **RTL &amp; i18n Support** – Full right-to-left compatibility + multilingual translations
- 🌙 **Dark Mode Support** – Auto dark/light mode matching system preferences
- 🛡 **Granular Consent Control** – Category-level cookie management (necessary/analytics/marketing)
- 📦 **Complete Customization** – Override every color, text, and layout via config
- 📱 **Responsive Design** – Perfectly adapts to all devices (mobile/tablet/desktop)
- 🧩 **No Frontend Dependencies** – No jQuery, Bootstrap, or Tailwind required — works everywhere effortlessly

---

🚀 Live Demo
-----------

[](#-live-demo)

👉 [Try the Live Demo](https://rixetbd.com/docs?package=laravel-cookie-consent)

[![Live Demo Thumbnail](https://camo.githubusercontent.com/4262a2f8f10aba85638076522cb45949142db4efc5ac22772916e8517fd9b094/68747470733a2f2f726978657462642e636f6d2f73746f726167652f6170702f7075626c69632f7061636b6167652f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e742e77656270)](https://camo.githubusercontent.com/4262a2f8f10aba85638076522cb45949142db4efc5ac22772916e8517fd9b094/68747470733a2f2f726978657462642e636f6d2f73746f726167652f6170702f7075626c69632f7061636b6167652f64657672616269756c2f6c61726176656c2d636f6f6b69652d636f6e73656e742e77656270)

---

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

[](#installation)

To get started with Cookie Consent, follow these simple steps:

1. Install the package via Composer:

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

2. Publish the package resources by running: (Normal publish)

```
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"
```

Basic Usage
-----------

[](#basic-usage)

Include these components in your Blade templates:

1. Add styles in the `` section:

```
{!! CookieConsent::styles() !!}
```

2. Add scripts before closing ``:

```
{!! CookieConsent::scripts() !!}
```

### Complete Example

[](#complete-example)

```
DOCTYPE html>

    Your Page
    {!! CookieConsent::styles() !!}

    {!! CookieConsent::scripts() !!}

```

Advanced Configuration
----------------------

[](#advanced-configuration)

```
DOCTYPE html>

    Your Page
    {!! CookieConsent::styles() !!}

    {!! CookieConsent::scripts(options: [
        'cookie_lifetime' => config('laravel-cookie-consent.cookie_lifetime', 7),
        'reject_lifetime' => config('laravel-cookie-consent.reject_lifetime', 1),
        'disable_page_interaction' => config('laravel-cookie-consent.disable_page_interaction', true),
        'preferences_modal_enabled' => config('laravel-cookie-consent.preferences_modal_enabled', true),
        'consent_modal_layout' => config('laravel-cookie-consent.consent_modal_layout', 'bar-inline'),
        'flip_button' => config('laravel-cookie-consent.flip_button', true),
        'theme' => config('laravel-cookie-consent.theme', 'default'),
        'cookie_prefix' => config('laravel-cookie-consent.cookie_prefix', 'Laravel_App'),
        'policy_links' => config('laravel-cookie-consent.policy_links', [
            ['text' => CookieConsent::translate('Privacy Policy'), 'link' => url('privacy-policy')],
            ['text' => CookieConsent::translate('Terms & Conditions'), 'link' => url('terms-and-conditions')],
        ]),
        'cookie_categories' => config('laravel-cookie-consent.cookie_categories', [
            'necessary' => [
                'enabled' => true,
                'locked' => true,
                'js_action' => 'loadGoogleAnalytics',
                'title' => CookieConsent::translate('Essential Cookies'),
                'description' => CookieConsent::translate('These cookies are essential for the website to function properly.'),
            ],
            'analytics' => [
                'enabled' => env('COOKIE_CONSENT_ANALYTICS', false),
                'locked' => false,
                'title' => CookieConsent::translate('Analytics Cookies'),
                'description' => CookieConsent::translate('These cookies help us understand how visitors interact with our website.'),
            ],
            'marketing' => [
                'enabled' => env('COOKIE_CONSENT_MARKETING', false),
                'locked' => false,
                'js_action' => 'loadFacebookPixel',
                'title' => CookieConsent::translate('Marketing Cookies'),
                'description' => CookieConsent::translate('These cookies are used for advertising and tracking purposes.'),
            ],
            'preferences' => [
                'enabled' => env('COOKIE_CONSENT_PREFERENCES', false),
                'locked' => false,
                'js_action' => 'loadPreferencesFunc',
                'title' => CookieConsent::translate('Preferences Cookies'),
                'description' => CookieConsent::translate('These cookies allow the website to remember user preferences.'),
            ],
        ]),
        'cookie_title' => CookieConsent::translate('Cookie Disclaimer'),
        'cookie_description' => CookieConsent::translate('This website uses cookies to enhance your browsing experience, analyze site traffic, and personalize content. By continuing to use this site, you consent to our use of cookies.'),
        'cookie_modal_title' => CookieConsent::translate('Cookie Preferences'),
        'cookie_modal_intro' => CookieConsent::translate('You can customize your cookie preferences below.'),
        'cookie_accept_btn_text' => CookieConsent::translate('Accept All'),
        'cookie_reject_btn_text' => CookieConsent::translate('Reject All'),
        'cookie_preferences_btn_text' => CookieConsent::translate('Manage Preferences'),
        'cookie_preferences_save_text' => CookieConsent::translate('Save Preferences'),
    ]) !!}

```

### 🌙 Enable Dark Mode

[](#-enable-dark-mode)

Add `theme="dark"` to your `` tag to automatically enable dark mode.

```

```

---

Theme Preset Support
--------------------

[](#theme-preset-support)

This package now supports **preset color themes** for cookie banners. You can choose from:

PresetDescription`basic`Default neutral theme, clean and simple.`modern-blue`Professional blue style, ideal for SaaS/web apps.`trust-green`Privacy-friendly green, promotes trust and eco-friendly vibes.`soft-neutral`Minimal soft gray, subtle and non-intrusive.`dark`Dark mode theme, low-light friendly.### How to configure

[](#how-to-configure)

In `config/cookie-consent.php`:

```
/*
|--------------------------------------------------------------------------
| Theme Preset
|--------------------------------------------------------------------------
| basic        - Default neutral theme
| modern-blue  - Professional blue style
| trust-green  - Privacy-friendly green style
| soft-neutral - Minimal soft gray theme
| dark         - Dark theme
*/
'theme_preset' => env('COOKIE_CONSENT_THEME_PRESET', 'basic'),
```

---

### 🌐 Enable RTL Mode

[](#-enable-rtl-mode)

Add `dir="rtl"` to your `` tag to enable right-to-left layout for RTL languages.

```

```

Layout Options
--------------

[](#layout-options)

### Config Status Control

[](#config-status-control)

```
COOKIE_CONSENT_ENABLED=true
COOKIE_CONSENT_PREFERENCES_ENABLED=true
COOKIE_CONSENT_ASSET_URL=https://your-domain.com // if you are in localhost, avoid this or put null

COOKIE_CONSENT_ANALYTICS=true
COOKIE_CONSENT_MARKETING=true
COOKIE_CONSENT_PREFERENCES=true
```

### Consent Modal Styles

[](#consent-modal-styles)

- **`box`** - Compact floating dialog
- **`box-inline`** - Inline positioned box
- **`box-wide`** - Expanded floating dialog
- **`cloud`** - Modern floating design
- **`cloud-inline`** - Compact cloud variant
- **`bar`** - Top/bottom banner
- **`bar-inline`** - Compact banner

*Default: `box-wide`*

### Preferences Modal Styles

[](#preferences-modal-styles)

- **`bar`** - Full-width layout
- **`box`** - Centered popup

*Default: `bar`*

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

[](#configuration)

Edit `config/cookie-consent.php` to modify:

- Cookie lifetimes
- Custom asset URL
- Visual styles
- Text content
- Category settings

### Example service loader (replace with your actual implementation)

[](#example-service-loader-replace-with-your-actual-implementation)

```
function loadGoogleAnalytics() {
    // Please put your GA script in loadGoogleAnalytics()
    // You can define function name from - {!! CookieConsent::scripts() !!}

    window.dataLayer = window.dataLayer || [];

    function gtag() {
        dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'YOUR_GA_ID');

    // Load the GA script
    const script = document.createElement('script');
    script.src = 'https://www.googletagmanager.com/gtag/js?id=YOUR_GA_ID';
    script.async = true;
    document.head.appendChild(script);
}

function loadFacebookPixel() {
    // Please put your marketing script in loadFacebookPixel()
    // You can define function name from - {!! CookieConsent::scripts() !!}

    !function (f, b, e, v, n, t, s) {
        if (f.fbq) return;
        n = f.fbq = function () {
            n.callMethod ?
                n.callMethod.apply(n, arguments) : n.queue.push(arguments)
        };
        if (!f._fbq) f._fbq = n;
        n.push = n;
        n.loaded = !0;
        n.version = '2.0';
        n.queue = [];
        t = b.createElement(e);
        t.async = !0;
        t.src = v;
        s = b.getElementsByTagName(e)[0];
        s.parentNode.insertBefore(t, s)
    }(window, document, 'script',
        'https://connect.facebook.net/en_US/fbevents.js');
    fbq('init', 'YOUR_PIXEL_ID');
    fbq('track', 'PageView');
}
```

---

Change Cookie Preferences Link
------------------------------

[](#change-cookie-preferences-link)

To comply with UK ICO and GDPR regulations, users **must be able to revisit and update their cookie preferences at any time**. This package now supports that functionality out of the box.

You can add a link anywhere on your site to let users open the cookie preferences modal again and update their choices:

```
Change Cookie Preferences
```

Or use the class-based approach (useful if you want to attach event handlers via JavaScript or multiple links):

```
Change Cookie Preferences
```

### How It Works

[](#how-it-works)

- Clicking the link will **show the cookie preferences modal**, allowing the user to change their settings.
- This feature **resets the consent banner/modal visibility** so users can modify their choices in compliance with the ICO’s requirement.
- The modal respects existing preferences but allows full customization and saving new preferences.

---

Compliance with UK ICO and GDPR
-------------------------------

[](#compliance-with-uk-ico-and-gdpr)

This package is designed to help your Laravel application meet the requirements of the UK Information Commissioner’s Office (ICO) and the GDPR by:

- **Providing explicit, granular cookie consent** with customizable categories (e.g., necessary, analytics, marketing, preferences).
- **Allowing users to easily revisit and change their cookie preferences** at any time using the “Change Cookie Preferences” link.
- Supporting **clear cookie banners and modals** with translations and accessibility considerations.
- Enabling **consent logging and event dispatching** for auditing and analytics purposes.

For more details, please review the UK ICO guidance on cookies: [ICO Guide to Cookies and Similar Technologies](https://ico.org.uk/for-organisations/guide-to-pecr/cookies-and-similar-technologies/)

---

### 🎯 Get Started Today!

[](#-get-started-today)

Experience the magic of CookieConsent and enhance your Laravel applications with Cookie Consent.

🔗 **GitHub:** [Laravel Cookie Consent](https://github.com/devrabiul/laravel-cookie-consent)
🔗 \*\*Packagist: \*\*

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

[](#contributing)

We welcome contributions to CookieConsent! If you would like to contribute, please fork the repository and submit a pull request. For any issues or feature requests, please open an issue on GitHub.

Please:

1. Fork the repository
2. Create your feature branch
3. Submit a pull request

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

🌱 Treeware
----------

[](#-treeware)

This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/devrabiul/laravel-cookie-consent) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

Contact
-------

[](#contact)

For support or inquiries, please reach out to us at [Send Mail](mailto:devrabiul@gmail.com).

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity47

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.2% 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 ~65 days

Recently: every ~79 days

Total

6

Last Release

79d ago

Major Versions

v1.1 → v2.02026-02-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/9eaf28cb5d9d5d87660cbe335e7b82a08bc7801a40556c3a99740e22282d9e17?d=identicon)[devrabiul](/maintainers/devrabiul)

---

Top Contributors

[![devrabiul](https://avatars.githubusercontent.com/u/112581088?v=4)](https://github.com/devrabiul "devrabiul (45 commits)")[![rabiul6am](https://avatars.githubusercontent.com/u/128285760?v=4)](https://github.com/rabiul6am "rabiul6am (6 commits)")

---

Tags

cookie-consentgdprgdpr-cookielaravellaravel-cookie-consentphplaravelcookiebannergdprcomplianceprivacyconsent

### Embed Badge

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

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

###  Alternatives

[statikbe/laravel-cookie-consent

Cookie consent modal for EU

213396.7k](/packages/statikbe-laravel-cookie-consent)[martin-schenk/laravel-cookie-consent

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

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

PHPackages © 2026

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