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.
You can install the package via composer:
composer require jeffersongoncalves/laravel-cookie-consentRun the migrations to create the settings in the database:
php artisan migrateAdd head template.
@include('cookie-consent::cookie-consent-head')Add body template.
@include('cookie-consent::cookie-consent-body')Publish views (optional).
php artisan vendor:publish --tag=cookie-consent-viewsPublish settings migrations (optional).
php artisan vendor:publish --tag=cookie-consent-settings-migrationsAll settings are stored in the database using spatie/laravel-settings. You can access and modify them at runtime using the CookieConsentSettings class or the cookie_consent_settings() helper.
use JeffersonGoncalves\CookieConsent\Settings\CookieConsentSettings;
// Via helper
$settings = cookie_consent_settings();
// Via container
$settings = app(CookieConsentSettings::class);
// Read a value
$position = $settings->position;$settings = cookie_consent_settings();
$settings->position = 'top-right';
$settings->popup_background = '#000000';
$settings->save();| Property | Type | Default |
|---|---|---|
css_url |
string |
https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css |
js_url |
string |
https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js |
content_header |
string |
Cookies used on the website! |
content_message |
string |
This website uses cookies to ensure you get the best experience on our website. |
content_dismiss |
string |
Got it! |
content_allow |
string |
Allow cookies |
content_deny |
string |
Decline |
content_link |
string |
Learn more |
content_href |
?string |
null |
content_close |
string |
❌ |
content_target |
string |
_blank |
content_policy |
string |
Cookie Policy |
popup_background |
string |
#696969 |
popup_text |
string |
#FFFFFF |
popup_link |
string |
#FFFFFF |
button_background |
string |
transparent |
button_border |
string |
#f8e71c |
button_text |
string |
#f8e71c |
highlight_background |
string |
#f8e71c |
highlight_border |
string |
#f8e71c |
highlight_text |
string |
#000000 |
position |
string |
bottom-left |
theme |
string |
block |
| Top Left | Top Right |
|---|---|
![]() |
![]() |
| Bottom Left | Bottom Right |
![]() |
![]() |
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
This package uses the Osano CookieConsent plugin.
The MIT License (MIT). Please see License File for more information.




