All notable changes to laravel-cookies-consent
will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v4.0.0 - Multilingual Support & Better Theming - Breaking Changes in Configuration and Functionality - 2025-02-24
In order to conform with the European Union's General Data Protection Regulation (GDPR) and improve the user experience,
the Laravel Cookies Consent plugin has undergone a major update. This release includes a multi-language support in the
banner, in order to allow the banner to change when the locale
is changed. The plugin now supports multiple languages
in all the texts that are displayed to the user!
Also, in order to improve the flexibility and theming of the plugin, we now provide a _variables.css
file, which can
be used to customize the colors and fonts of the plugin. This file is located in the
public/vendor/scify/laravel-cookies-consent/styles
directory and can
be customized to match the design of your application.
- Multi-Language Support: The plugin now supports multiple languages in the banner and the cookies consent modal.
The texts displayed to the user can be translated based on the
locale
set in the application. By default, all 24 languages of the EU are supported. - Automatic locale detection: The plugin automatically detects the app's locale based on the Laravel locale, and displays the banner in the corresponding language.
- Customizable Theme: A
_variables.css
file is now being added to thepublic/vendor/scify/laravel-cookies-consent/styles
directory, once you publish the front-end assets. This file can be used to customize the colors and fonts of the plugin to match the design of your application. - Cookies categories collapsed by default: The cookies categories are now collapsed by default in the cookies
consent modal. Users can expand each category to view the cookies included in that category. This can be tweaked in
the
config/cookies_consent.php
file. - Improved UI/UX: The cookies consent modal has been updated with improved styling and layout for a better user experience.
If you want to override the CSS styles of the cookies consent dialog, you can do this:
<x-laravel-cookies-consent></x-laravel-cookies-consent>
<style>
#scify-cookies-consent {
--primary-color: #ff5722; /* Override primary color */
...
/* Add more override rules here */
}
</style>
The full list of CSS variables that can be overridden can be found in the
public/vendor/scify/laravel-cookies-consent/_variables.css
file.
The v4.0.0
release introduces significant changes to the config/cookies_consent.php
configuration file.
These changes are necessary to improve the flexibility and usability of the plugin. Below
are the details of the changes and the steps required to update your existing configuration.
Cookie Categories:
The structure of the cookies
array has been updated to reflect the new multi-language support.
Each cookie now has their description derived from the language files, based on the locale
set in the application.
Cookie Duration:
Each cookie category now includes a description
, duration
, and duration_count
attributes.
For example, if you want to set the duration of a cookie to 2 years
, you can set the duration
to
cookies_consent::messages.years
and the duration_count
to 2
.
The plugin will automatically translate the duration text, based on the locale
set in the application.
Cookies categories collapsed by default:
The cookies categories are now collapsed by default in the cookies consent modal. Users can expand each category to view
the cookies included in that category. This can be tweaked in the config/cookies_consent.php
file, in the
categories_collapsed_by_default
key.
- Backup your existing configuration file: Before updating to the new version, make sure to take a backup of your
existing
config/cookies_consent.php
file to avoid losing any custom settings. - Update the Configuration File: Run
php artisan vendor:publish --provider="SciFY\LaravelCookiesConsent\LaravelCookiesConsentServiceProvider" --tag=cookies-consent-config --force
and then ensure thecookie_prefix
is set in theconfig/cookies_consent.php
file. Update thedescription
,duration
, andduration_count
fields of each cookie in the cookies array to reflect the new JSON storage format. - Publish the Front-End Assets: Run the following command to publish the updated assets:
php artisan vendor:publish --provider="SciFY\LaravelCookiesConsent\LaravelCookiesConsentServiceProvider" --tag="cookies-consent-public" --force
- Build the Laravel configuration cache: Run the following command to rebuild the configuration cache:
php artisan config:cache
- Test Your Application: Ensure that the cookies consent functionality works as expected with the new JSON storage format. Verify that the cookies are correctly set and retrieved in the browser.
In order to simplify the installation process and avoid potential conflicts with existing assets, the front-end assets
are now included directly in the package and loaded from the vendor/scify/laravel-cookies-consent/
directory.
This means that the public/vendor/scify/laravel-cookies-consent
directory should be deleted, and the assets should be
published
again:
In order to update to the new version, you need to remove the public/vendor/scify/laravel-cookies-consent
directory
and run the
asset publishing command:
rm -rf public/vendor/scify/laravel-cookies-consent
And then:
php artisan vendor:publish \
--provider="SciFY\LaravelCookiesConsent\LaravelCookiesConsentServiceProvider" \
--tag="cookies-consent-public"
-
JSON Cookie Storage: Cookies are now stored in a JSON object under a single key with the prefix specified in the configuration file. This change improves the structure and management of cookies.
-
Configuration File Changes: The configuration file format has been updated to reflect the new JSON cookie storage method. The
cookie_prefix
is now used to store cookies in a JSON object.
- JSON Cookie Storage: Cookies are now stored in a JSON object under a single key with the prefix specified in the configuration file. This change improves the structure and management of cookies.
hide_floating_button_on_mobile
option: A new configuration option has been added to hide the floating cookies button on mobile devices. This option allows you to control the visibility of the floating button based on the device type.- UI/UX Improvements: The cookies consent modal has been updated with improved styling and layout for a better user experience.
- Update the configuration file to reflect the new JSON cookie storage method:
- Ensure the
cookie_prefix
is set in theconfig/cookies_consent.php
file. - Update the
name
field of each cookie in thecookies
array to reflect the new JSON storage format.
Example:
'cookie_prefix' => 'my_app_',
'cookies' => [
'strictly_necessary' => [
[
'name' => 'my_app_cookies_consent',
'description' => 'This cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.',
'duration' => '2 years',
'policy_external_link' => null,
],
// other cookies...
],
'targeting' => [
// cookies...
],
],
- Update Blade Files
- Update the Blade files to reflect the new JSON cookie storage method. The
cookie
helper function is used to set and retrieve cookies from the JSON object.
Example:
@if(isset($_COOKIE[config('cookies_consent.cookie_prefix') . 'cookies_consent']))
@php
$cookiesConsent = json_decode($_COOKIE[config('cookies_consent.cookie_prefix') . 'cookies_consent'], true);
@endphp
@if(isset($cookiesConsent['targeting']) && $cookiesConsent['targeting'] && config('app.google_analytics_id'))
<!-- Google Analytics -->
<script defer async>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
window.ga('create', '{{ config('app.google_analytics_id') }}', 'auto');
window.ga('set', 'anonymizeIp', true);
window.ga('send', 'pageview');
</script>
@endif
@endif
- Publish the front-end assets
- Run the following command to publish the updated assets:
php artisan vendor:publish --provider="SciFY\LaravelCookiesConsent\LaravelCookiesConsentServiceProvider" --tag="cookies-consent-assets" --force
- Test your application
- Ensure that the cookies consent functionality works as expected with the new JSON storage format.
- Verify that the cookies are correctly set and retrieved in the browser.
- Improved the UI design for smaller screens (phones & tablets)
- Fixed the width of the cookies container
The v2 of the Laravel Cookies Consent plugin has been released! 🎉🥳😍
This version includes some important changes and improvements, such as:
- A new configuration file format. Now you can declare the cookies each cookie category uses in a more structured way.
- A new, clean, and intuitive UI for the cookies consent modal.
- An option to present the cookies consent dialog in a separate page instead of a modal.
- A stick cookies button that allows users to change their cookies preferences at any time. This button is optional and it's existence can be tweaked in the configuration file.
- A separate page for the cookies preferences, where users can read more about each cookie category and change their preferences.
- Changed the background color of the "Allow all cookies" button, in order to be compliant with the GDPR rules
- Fixed the padding of the button texts
Added Portuguese Language corrections, thanks to this PR by ViNiSeNnAtt
Added Portuguese Language, thanks to this commit by ViNiSeNnAtt
Improvements regarding the styles file, Composer lib updates
List of Updates:
- Fixed z-index issue (as reported in #10)
- Now the front-end assets (styles) file is not automatically published, to avoid causing overriding (reported
in #11) - Composer libraries update
- Improved Development guidelines in Readme file
Notable Changes:
Now, in order to publish the styles file to public/vendor/scify/laravel-cookies-consent/css/style.css
it is **required
** to manually
run the publishing command:
php artisan vendor:publish \
--provider="SciFY\LaravelCookiesConsent\LaravelCookiesConsentServiceProvider" \
--tag="cookies-consent-assets"
This release addresses this issue, regarding the cookie prefix when accepting "all" cookies.
This is the first stable release of the plugin! Feel free to download, try and customize it. If you find any issues, please report them to the issue page. Check out the CONTRIBUTING.md guide to contribute to this open-source project!
The plugin now uses Laravel's app()->langPath()
method, in order to publish the translation files.
Set the required PHP version to either 7.x
or 8.x
, in order to accommodate older Laravel installations.
- Now the cookie prefix is set entirely from the configuration file. The trailing character should be set there.
- Improved UI design in smaller (phone & tablet) screens.
- The plugin is now ready to be tested and used in 3rd party Laravel apps.
Improved the overall design and fixed the width of the cookies container
- Added the ability to set cookie duration
- Fixed container width on larger screens
- Added remaining languages
- Improved README.md instructions
This is the initial release of the plugin. SciFY Team will start testing the plugin in our own projects and proceed to the release of version 1.0.0, when deem applicable.