All Projects → spatie → Laravel Cookie Consent

spatie / Laravel Cookie Consent

Licence: mit
Make your Laravel app comply with the crazy EU cookie law

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Laravel Cookie Consent

Barcode
Laravel 5 Barcode Generator
Stars: ✭ 826 (-7.71%)
Mutual labels:  laravel
Lvlgrid
✨ Grid helper to your Laravel application. Filter, order and pagination ajax
Stars: ✭ 7 (-99.22%)
Mutual labels:  laravel
Laravel Collection Macros
Custom Laravel Collection Macros.
Stars: ✭ 17 (-98.1%)
Mutual labels:  laravel
Package Skeleton
📦 My base for PHP packages.
Stars: ✭ 6 (-99.33%)
Mutual labels:  laravel
Scaffold Interface
🚀 A Smart CRUD Generator For Laravel
Stars: ✭ 836 (-6.59%)
Mutual labels:  laravel
Laravel Stager
Laravel Stager State Machine, Its purpose is to add state machine functionality to models
Stars: ✭ 16 (-98.21%)
Mutual labels:  laravel
Laravel Jade
[Discontinued] Laravel package that adds Jade templating support
Stars: ✭ 5 (-99.44%)
Mutual labels:  laravel
Laravel Bigbluebutton
A BigBlueButton API wrapper for Laravel 5
Stars: ✭ 17 (-98.1%)
Mutual labels:  laravel
Laravel Uptime Monitor
A powerful and easy to configure uptime and ssl monitor
Stars: ✭ 837 (-6.48%)
Mutual labels:  laravel
Laravel Jsonapi
Basic setup framework for creating a Laravel JSON-API server
Stars: ✭ 16 (-98.21%)
Mutual labels:  laravel
Laravel Sluggable
An opinionated package to create slugs for Eloquent models
Stars: ✭ 831 (-7.15%)
Mutual labels:  laravel
Aetherupload Laravel
A Laravel package to upload large files 上传大文件的Laravel扩展包
Stars: ✭ 835 (-6.7%)
Mutual labels:  laravel
Acwa book ru
Книга "Архитектура сложных веб-приложений. С примерами на Laravel"
Stars: ✭ 886 (-1.01%)
Mutual labels:  laravel
Menu
Menu and sidebar management package for Laravel
Stars: ✭ 6 (-99.33%)
Mutual labels:  laravel
Mini Crm
Mini CRM with Laravel API and react-native
Stars: ✭ 17 (-98.1%)
Mutual labels:  laravel
Adldap2 Laravel
LDAP Authentication & Management for Laravel
Stars: ✭ 825 (-7.82%)
Mutual labels:  laravel
Laravel Collectable
Stars: ✭ 7 (-99.22%)
Mutual labels:  laravel
Identity Number
Validator for Swedish personal identity numbers (personnummer). For use "standalone" or with Laravel.
Stars: ✭ 17 (-98.1%)
Mutual labels:  laravel
Angular5.2 Laravel5.6
Angular 5.2 and Laravel 5.6 Authentication and CRUD
Stars: ✭ 17 (-98.1%)
Mutual labels:  laravel
Laravel Bootstrap Table List
Bootstrap table list generator for Laravel.
Stars: ✭ 16 (-98.21%)
Mutual labels:  laravel

Make your Laravel app comply with the crazy EU cookie law

Latest Version on Packagist Software License GitHub Workflow Status Total Downloads

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.

This package provides an easily configurable view to display the message. Also included is JavaScript code to set a cookie when a user agrees with the cookie policy. The package will not display the dialog when that cookie has been set.

Spatie is a web design agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-cookie-consent

The package will automatically register itself.

Optionally you can publish the config-file:

php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="config"

This is the contents of the published config-file:

return [

    /*
     * Use this setting to enable the cookie consent dialog.
     */
    'enabled' => env('COOKIE_CONSENT_ENABLED', true),

    /*
     * The name of the cookie in which we store if the user
     * has agreed to accept the conditions.
     */
    'cookie_name' => 'laravel_cookie_consent',

    /*
     * Set the cookie duration in days.  Default is 365 * 20.
     */
    'cookie_lifetime' => 365 * 20,
];

Usage

To display the dialog all you have to do is include this view in your template:

//in your blade template
@include('cookieConsent::index')

This will render the following dialog that, when styled, will look very much like this one.

dialog

Please be aware that the package does not provide any styling, this is something you'll need to do yourself.

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

Customising the dialog texts

If you want to modify the text shown in the dialog you can publish the lang-files with this command:

php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="lang"

This will publish this file to resources/lang/vendor/cookieConsent/en/texts.php.

return [
    'message' => 'Please be informed that this site uses cookies.',
    'agree' => 'Allow cookies',
];

If you want to translate the values to, for example, French, just copy that file over to resources/lang/vendor/cookieConsent/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:

php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="views"

This will copy the index and dialogContents view files over to resources/views/vendor/cookieConsent. 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 cookieConsent::index in your view you could opt to add the Spatie\CookieConsent\CookieConsentMiddleware to your kernel:

// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \Spatie\CookieConsent\CookieConsentMiddleware::class,
    ];

    // ...
}

This will automatically add cookieConsent::index to the content of your response right before the closing body tag.

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

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].