2017 © Pedro Peláez
 

library laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

image

spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  • Monday, July 30, 2018
  • by Spatie
  • Repository
  • 10 Watchers
  • 367 Stars
  • 101,935 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 44 Forks
  • 1 Open issues
  • 30 Versions
  • 22 % Grown

The README.md

Simple, customizable cookie consent message for Laravel

Latest Version on Packagist Software License run-tests Total Downloads, (*1)

This package adds a simple, customizable cookie consent message to your site. When the site loads, the banner appears and lets users consent to cookies. Once consent is given, the banner hides and stays hidden., (*2)

What this package does not: - Include an option to 'Decline' all cookies, which might be required. - Block trackers and cookies before consent. You need to handle this yourself. - Include options for different consent categories like "Necessary" or "Marketing"., (*3)

For more advanced cookie consent options in Laravel, consider these alternatives., (*4)

Support us

, (*5)

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., (*6)

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., (*7)

Installation

You can install the package via composer:, (*8)

``` bash composer require spatie/laravel-cookie-consent, (*9)


The package will automatically register itself. Optionally you can publish the config-file: ```bash php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-config"

This is the contents of the published config-file:, (*10)

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,
];

The cookie domain is set by the 'domain' key in config/session.php, make sure you add a value in your .env for SESSION_DOMAIN. If you are using a domain with a port in the url such as 'localhost:3000', this package will not work until you do so., (*11)

Usage

To display the dialog all you have to do is include this view in your template:, (*12)

//in your blade template
@include('cookie-consent::index')

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

dialog, (*14)

The default styling provided by this package uses TailwindCSS v2 to provide a floating banner at the bottom of the page., (*15)

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, (*16)

Customising the dialog texts

If you want to modify the text shown in the dialog you can publish the lang-files with this command:, (*17)

php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="cookie-consent-translations"

This will publish this file to resources/lang/vendor/cookie-consent/en/texts.php., (*18)

```php, (*19)

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

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., (*21)

Customising the dialog contents

If you need full control over the contents of the dialog. You can publish the views of the package:, (*22)

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

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., (*23)

Using the middleware

Instead of including cookie-consent::index in your view you could opt to add the Spatie\CookieConsent\CookieConsentMiddleware to your kernel:, (*24)

// app/Http/Kernel.php

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

    // ...
}

This will automatically add cookie-consent::index to the content of your response right before the closing body tag., (*25)

Notice

We are not lawyers and can't provide legal advice. Consult legal professionals what rules apply to your project., (*26)

Changelog

Please see CHANGELOG for more information what has changed recently., (*27)

Testing

bash composer test, (*28)

Contributing

Please see CONTRIBUTING for details., (*29)

Security

If you discover any security-related issues, please email freek@spatie.be instead of using the issue tracker., (*30)

Credits

License

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

The Versions

30/07 2018

dev-master

9999999-dev https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply cookie-consent

22/06 2018

dev-analysis-XlaGOr

dev-analysis-XlaGOr https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

28/05 2018

dev-analysis-zOKE40

dev-analysis-zOKE40 https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

02/02 2018

2.2.0

2.2.0.0 https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

24/10 2017

2.1.0

2.1.0.0 https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

28/09 2017

dev-revert-53-patch-1

dev-revert-53-patch-1 https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

30/08 2017

2.0.0

2.0.0.0 https://github.com/spatie/cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply cookie-consent

07/11 2016
30/10 2016
11/10 2016
06/10 2016
23/09 2016
23/09 2016
23/09 2016

dev-analysis-8nKOOG

dev-analysis-8nKOOG https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

07/09 2016

1.3.0

1.3.0.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

23/08 2016

dev-analysis-86wA1a

dev-analysis-86wA1a https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

13/07 2016

1.2.2

1.2.2.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

04/07 2016

1.2.1

1.2.1.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

01/07 2016

1.2.0

1.2.0.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

30/06 2016

1.1.0

1.1.0.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

28/06 2016

1.0.1

1.0.1.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

28/06 2016

1.0.0

1.0.0.0 https://github.com/spatie/laravel-cookie-consent

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu laravel-cookie-consent law comply

27/06 2016

0.0.1

0.0.1.0 https://github.com/spatie/laravel-cookie-comply

Make your Laravel app comply with the crazy EU cookie law

  Sources   Download

MIT

The Requires

 

The Development Requires

cookie spatie eu law comply laravel-cookie-comply