Menü

Laravel Cookie Consent: A GDPR-Compliant Solution

Easily implement a customizable, GDPR-compliant cookie consent solution in your Laravel application.

Laravel-Cookie-Consent.png

Many websites must provide users with transparent choices about how their data is handled beyond a basic cookie consent banner to comply with regulations like the General Data Protection Regulation (GDPR). Muhammad Rabiul's Laravel Cookie Consent package adds a fully customizable, GDPR-compliant cookie consent solution to your Laravel application.

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 (Essential/Analytics/Marketing)
  • Automatic Script Blocking: This feature prevents non-essential scripts from running until user consent is obtained, improving performance and compliance.
  • Complete Customization: Override the colors, message, and layout via config
  • Responsive Design: Perfectly adapts to all devices (mobile/tablet/desktop)

To get started with Cookie Consent in your project, install it via Composer:

composer require devrabiul/laravel-cookie-consent

Next, publish the package resources:

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

Lastly, in your Blade template, add {!! CookieConsent::styles() !!} to the <head> tag and {!! CookieConsent::scripts() !!} just before the closing </body> tag. For example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laravel Cookie Consent Demo</title>
    {!! CookieConsent::styles() !!}
</head>
<body>
 
    <!-- Your amazing content -->
 
    {!! CookieConsent::scripts() !!}
</body>
</html>

 

Editing the config/cookie-consent.php file allows you to configure cookie lifetimes, visual styles, text content, and category settings.

Learn more about this package, how to do advanced configuration, and view the source code on GitHub.

 

Yorumlar (0)

Bu yazıya henüz yorum yapılmamış. İlk yorumu siz yapın!

Yorum Yap