Download the PHP package aonodevs/laravel-cookie-consent without Composer
On this page you can find all versions of the php package aonodevs/laravel-cookie-consent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aonodevs/laravel-cookie-consent
More information about aonodevs/laravel-cookie-consent
Files in aonodevs/laravel-cookie-consent
Package laravel-cookie-consent
Short Description Make your Laravel app comply with the crazy EU cookie law
License MIT
Homepage https://github.com/retinens/laravel-cookie-consent
Informations about the package laravel-cookie-consent
Make your Laravel app comply with the refuse/accept cookie law
All sites owned by EU citizens or targeted towards EU citizens must comply with a crazy EU law. This law requires a dialog to be displayed to inform the users of your websites how cookies are being used. You can read more info on the legislation on the site of the European Commission.
The users should be presented the option to agree or disagree with the optional cookies.
This package is based on the spatie/laravel-cookie-consent package by the good folks at Spatie.
This package provides an easily configurable view to display the message. Also included is JavaScript code to set a cookie when a user agrees or disagrees with the cookie policy. The user can also disagree, and the cookie is set the 0. The package will not display the dialog when that cookie has been set.
Installation
You can install the package via composer:
The package will automatically register itself.
Optionally you can publish the config-file:
This is the contents of the published config-file:
Usage
To display the dialog all you have to do is include this view in your template:
This will render the following dialog that, when styled, will look very much like this one.
The default styling provided by this package uses TailwindCSS v2 to provide a floating banner at the bottom of the page.
When the user clicks "Allow cookies" a laravel_cookie_consent
cookie will be set and the dialog will be removed from the DOM. On the next request, Laravel will notice that the laravel_cookie_consent
has been set and will not display the dialog again
Refuse button
If you want to add a refuse button to the dialog, you can enable the option in the config file. When the user clicks on "Refuse non-essential cookies" a laravel_cookie_consent
cookie will be set with the value of 0
.
Customising the dialog texts
If you want to modify the text shown in the dialog you can publish the lang-files with this command:
This will publish this file to resources/lang/vendor/cookie-consent/en/texts.php
.
If you want to translate the values to, for example, French, just copy that file over to resources/lang/vendor/cookie-consent/fr/texts.php
and fill in the French translations.
Customising the dialog contents
If you need full control over the contents of the dialog. You can publish the views of the package:
This will copy the index
and dialogContents
view files over to resources/views/vendor/cookie-consent
. You probably only want to modify the dialogContents
view. If you need to modify the JavaScript code of this package you can do so in the index
view file.
Using the middleware
Instead of including cookie-consent::index
in your view you could opt to add the Retinens\CookieConsent\CookieConsentMiddleware
to your kernel:
This will automatically add cookie-consent::index
to the content of your response right before the closing body tag.
Helper
In your code you can use the facade to get the info if the user has accepted or not the non-essential cookies.
That way you can (or not) add cookies for the user, or add scripts into the header.
Notice
The legislation is pretty very vague on how to display the warning, which texts are necessary, and what options you need to provide. This package will go a long way towards compliance, but if you want to be 100% sure that your website is ok, you should consult a legal expert.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-cookie-consent with dependencies
illuminate/support Version ^7.0|^8.0
illuminate/view Version ^7.0|^8.0
illuminate/cookie Version ^7.0|^8.0
spatie/laravel-package-tools Version ^1.6