Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

laravel-cookie-consent

> 后端框架
Open source

A GDPR-compliant solution offering enterprise-grade compliance with fully customizable cookie banners for Laravel applications.

184 stars0 likes3 views
WebsiteGitHub

About

A GDPR-compliant solution offering enterprise-grade compliance with fully customizable cookie banners for Laravel applications.

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.

Features

  • One-Click Implementation – Simple installation via Composer with auto-loaded assets
  • ⚡ Zero Performance Impact – Lightweight with lazy-loaded components
  • RTL & 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

Try the Live Demo


Installation

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

  1. Install the package via Composer:
bash
composer require devrabiul/laravel-cookie-consent
  1. Publish the package resources by running: (Normal publish)
bash
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"

Basic Usage

Include these components in your Blade templates:

  1. Add styles in the `` section:
php
{!! CookieConsent::styles() !!}
  1. Add scripts before closing ``:
php
{!! CookieConsent::scripts() !!}

Complete Example

php

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

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

Advanced Configuration

…

Enable Dark Mode

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

xml

Theme Preset Support

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

Preset Description
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

In config/cookie-consent.php:

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

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

xml

Layout Options

Config Status Control

bash
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

  • 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

  • bar - Full-width layout
  • box - Centered popup

Default: bar

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)

…

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:

xml
Change Cookie Preferences

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

xml
Change Cookie Preferences

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

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


Get Started Today!

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

GitHub: Laravel Cookie Consent
**Packagist: ** https://packagist.org/packages/devrabiul/laravel-cookie-consent

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

This package is open-sourced software licensed under the MIT license.

Treeware

This package is Treeware. If you use it in production, then we ask that you buy the world a tree 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

For support or inquiries, please reach out to us at Send Mail.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPcookie-consentgdprgdpr-cookielaravel

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架