Advanced File Manager for Laravel is coming soon! Subscribe for updates and early access. 🚀

No recent searches

Composer Package GDPR Compliant MIT License

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.

🔥 One-Click Implementation
⚡ Zero Performance Impact
🌍 RTL & i18n Support
🌙 Dark Mode Support
🛡 Granular Consent Control
📦 Complete Customization
📱 Responsive Design
🧩 No Frontend Dependencies
Cookie Disclaimer
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.
Installation

Set Up in Seconds

1
Install via Composer
composer require devrabiul/laravel-cookie-consent
2
Publish Resources
php artisan vendor:publish --provider="Devrabiul\CookieConsent\CookieConsentServiceProvider"
Basic Usage

Include these components in your Blade templates to activate the banner site-wide.

Add styles in <head>:
Add scripts before </body>:
Dark Mode
<body theme="dark">
RTL Support
<body dir="rtl">
Advanced Options

Directly pass options to the scripts() helper to override global config.










Layout Options
CONSENT MODAL STYLES
  • box
  • box-inline
  • box-wide
  • cloud
  • bar
  • bar-inline
PREFERENCES MODAL STYLES
  • bar
  • box
Config Status (.env)
# Global Toggle
COOKIE_CONSENT_ENABLED=true
COOKIE_CONSENT_PREFERENCES_ENABLED=true

# Category Toggles
COOKIE_CONSENT_ANALYTICS=true
COOKIE_CONSENT_MARKETING=true
COOKIE_CONSENT_PREFERENCES=true
Service Loader Examples

Define these functions in your JS to trigger scripts only after consent is given.

function loadGoogleAnalytics() {
    window.dataLayer = window.dataLayer || [];
    function gtag() { dataLayer.push(arguments); }
    gtag('js', new Date());
    gtag('config', 'YOUR_GA_ID');

    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() {
    !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');
}
UK ICO and GDPR Compliance

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

  • Granular Consent: Separate categories for necessary, analytics, marketing, and preferences.
  • Consent Revisibility: Allows users to revisit and update choices at any time.
  • Event Logging: Support for consent logging and event dispatching for auditing.
Compliance Helper
<a onclick="showHideToggleCookiePreferencesModal()">Change Cookie Preferences</a>
Include this link in your footer to satisfy ICO "revisitable consent" rules.

GitHub Sponsors

Support the maintainer to keep it updated.

Sponsor Now

Sustainability

We buy a tree for every sponsorship.

Buy Us A Tree

Join the Development

Fork the repository and submit a pull request if you want to contribute.

RixetBD