spatie/laravel-cookie-consent
Add a simple, customizable cookie consent banner to Laravel. Shows on first visit, stores consent, then stays hidden. No “decline” option, no tracker blocking, and no consent categories—use other tools if you need advanced compliance features.
composer require spatie/laravel-cookie-consentphp artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-config"@include('cookie-consent::index')First use case: quickly add EU-compliant cookie consent to an existing Laravel app by embedding the view in your main layout—no configuration needed.
@include('cookie-consent::index') into your main Blade layout (e.g., layouts/app.blade.php). The banner appears only once per user (stored in cookie).\Spatie\CookieConsent\CookieConsentMiddleware::class to global middleware stack to auto-append banner without manual Blade includes—ideal for template-heavy apps.--tag="cookie-consent-translations"), then add locale files like resources/lang/vendor/cookie-consent/fr/texts.php.--tag="cookie-consent-views"), then override dialogContents.blade.php to modify structure, and index.blade.php to tweak JS behavior..js-cookie-consent via CSS for custom positioning (e.g., fixed bottom-right corner).COOKIE_CONSENT_ENABLED=false in .env (e.g., for local dev) to suppress the banner.SESSION_DOMAIN is set correctly in .env. The banner won’t persist across subdomains without this.whitecube/laravel-cookie-consent.TrustProxies and before PreventRequestsDuringMaintenance to avoid cookie domain issues.@include with SSR fallback or dynamic view rendering.CookieConsentMiddleware to handle that case.laravel_cookie_consent cookie and set APP_ENV=local/COOKIE_CONSENT_ENABLED=true in .env.testing to ensure tests hit the consent flow.@include, remove the explicit include to prevent duplicate banners.How can I help you explore Laravel packages today?