Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Cookie Consent

Laravel Cookie Consent Laravel Package

jeffersongoncalves/laravel-cookie-consent

Simple Laravel cookie consent banner with GDPR/CCPA-friendly preferences. Drop-in head/body includes, optional view publishing for customization, and settings stored in the database via spatie/laravel-settings with helper access for runtime updates.

View on GitHub
Deep Wiki
Context7

This Laravel package provides a simple and elegant way to implement cookie consent on your website, ensuring compliance with privacy regulations like GDPR and CCPA. It offers a clean and customizable interface, allowing you to easily manage and display cookie consent banners and preferences.

Frequently asked questions about Laravel Cookie Consent
How do I install and set up Laravel Cookie Consent in a Laravel 13 project?
Run `composer require jeffersongoncalves/laravel-cookie-consent`, then execute `php artisan migrate` to create the settings table. Add `@include('cookie-consent::cookie-consent-head')` and `@include('cookie-consent::cookie-consent-body')` to your layout file. No additional configuration is needed for basic usage.
Does this package support GDPR and CCPA compliance out of the box?
Yes, the package is explicitly designed for GDPR/CCPA compliance with structured consent management. It includes settings for necessary/analytics cookies and provides a foundation for CCPA’s 'Do Not Sell' requirements, though you may need to add a manual link for full CCPA compliance.
Can I customize the cookie consent banner’s appearance beyond the default theme?
You can publish the views with `php artisan vendor:publish --tag=cookie-consent-views` and modify the Blade templates in `resources/views/vendor/cookie-consent`. For deeper customization, override the underlying Osano library’s CSS or use the published assets tag to inject custom styles.
What Laravel versions and PHP requirements does this package support?
The package supports Laravel 9 through 13.x and requires PHP 8.1+. It is compatible with modern Laravel stacks but does not support Lumen. Always check the latest release notes for updates on supported versions.
How do I block scripts until a user gives cookie consent?
Create a middleware like `CheckCookieConsent` that checks for the `cookie_consent` cookie. Use it in your `Kernel.php` to block access to routes requiring consent. Example: `if (!$request->cookie('cookie_consent') && !$request->ipIsTrusted()) { abort(403); }`
Is there a way to add multi-language support for the cookie consent banner?
The package no longer includes built-in i18n support in v3.x, but you can manually override the published views in `resources/views/vendor/cookie-consent` and implement language-specific translations. Use Laravel’s localization features to dynamically load the correct text based on the user’s locale.
What happens if the CDN hosting the cookie consent assets goes down?
The package relies on CDN-hosted assets by default, but you can publish them locally with `php artisan vendor:publish --tag=cookie-consent-assets` to ensure availability. This is a good practice for production environments where uptime is critical.
Can I integrate this package with Google Analytics or other analytics tools?
The package does not include built-in analytics integration, but you can manually implement it using middleware or JavaScript. For example, block analytics scripts until consent is given, then load them dynamically based on the user’s consent status.
Are there any alternatives to this package for Laravel cookie consent?
Alternatives include `orangehill/isee` (for GDPR compliance) and `spatie/cookie-consent` (simpler but less feature-rich). This package stands out for its integration with `spatie/laravel-settings` for runtime configuration and its use of the Osano library for advanced cookie management.
How do I update the package settings dynamically in real-time?
Use the `CookieConsentSettings` class or the `cookie_consent_settings()` helper to access and modify settings at runtime. For example, `$settings = cookie_consent_settings(); $settings->position = 'bottom-right'; $settings->save();` This is useful for A/B testing or adjusting compliance text without redeploying.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor