PHPackages                             keepsuit/laravel-cookie-solution - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. keepsuit/laravel-cookie-solution

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

keepsuit/laravel-cookie-solution
================================

Make your site comply with EU cookie law

1.6.0(2mo ago)27.1k↓14.3%MITPHPPHP ^8.2CI passing

Since Jan 26Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/keepsuit/laravel-cookie-solution)[ Packagist](https://packagist.org/packages/keepsuit/laravel-cookie-solution)[ Docs](https://github.com/keepsuit/laravel-cookie-solution)[ RSS](/packages/keepsuit-laravel-cookie-solution/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (27)Versions (44)Used By (0)

Make your site comply with EU cookie law
========================================

[](#make-your-site-comply-with-eu-cookie-law)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fac29b5ac56f9c314a3a2043d088ca191d9aaff7e73acc3099093c80d403ba24/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b656570737569742f6c61726176656c2d636f6f6b69652d736f6c7574696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/keepsuit/laravel-cookie-solution)[![GitHub Tests Action Status](https://camo.githubusercontent.com/24351881e4f48816d38c12d4fa06b65db28628d8f1b3f072eaabd2bf817e054b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b656570737569742f6c61726176656c2d636f6f6b69652d736f6c7574696f6e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/keepsuit/laravel-cookie-solution/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a0fe338fbc6f3e69985f35c142cc32b3c81f5fcd75f3dd7aa8f95bc29b5d18de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b656570737569742f6c61726176656c2d636f6f6b69652d736f6c7574696f6e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/keepsuit/laravel-cookie-solution/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/89cd55949e2aca1254978add1f0a4a33c8015c1bbea21860fb20e00943ecb3be/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b656570737569742f6c61726176656c2d636f6f6b69652d736f6c7574696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/keepsuit/laravel-cookie-solution)

This package provides a configurable cookie banner for your Laravel application. It also includes templates for cookie policy and privacy policy pages.

Note that this package is not a legal advice. You should always consult a lawyer and change texts and policies for your needs.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require keepsuit/laravel-cookie-solution
```

You can publish the config file with:

```
php artisan vendor:publish --tag="cookie-solution-config"
```

This is the contents of the published config file:

```
return [
    /**
     * Enable or disable the cookie solution.
     */
    'enabled' => env('COOKIE_SOLUTION_ENABLED', true),

    /**
     * Name of the cookie where we store the user's consent.
     */
    'cookie_name' => 'laravel_cookie_solution',

    /**
     * The cookie's lifetime in days.
     */
    'cookie_lifetime' => 365,

    /**
     * Banner highlight color (ex. #3522dd).
     * If null, the default color will be used.
     */
    'highlight_color' => null,

    /**
     * Floating banner toggle
     * if false, the banner toggle will not be displayed.
     * You need to add "data-cookie-solution-toggle" attribute to an element to open the banner.
     */
    'toggle_enabled' => true,

    /**
     * Cookie toggle position (left or right).
     */
    'toggle_position' => 'right',

    /**
     * The entity responsible for the processing of the data.
     */
    'data_owner' => [
        /**
         * Email address of the data owner.
         */
        'contact_email' => null,

        /**
         * Name/Company name and address of the data owner.
         * This is parsed as Markdown (you can use __text__ for bold and _text_ for italic).
         */
        'name_and_address' => null,
    ],
];
```

Optionally, you can publish the assets, views and translations using.

```
php artisan vendor:publish --tag="cookie-solution-assets"
php artisan vendor:publish --tag="cookie-solution-views"
php artisan vendor:publish --tag="cookie-solution-translations"
```

If you publish the assets, remember to publish new versions when you update the package. You can automate this using composer `post-update-cmd` script:

```
{
    "scripts": {
        "post-update-cmd": [
            // ...
            "@php artisan vendor:publish --tag=cookie-solution-assets --force"
        ]
    }
}
```

Usage
-----

[](#usage)

Include the cookie solution script in your layout (it's recommended to include it in the `` tag):

```
@include('cookie-solution::script')
```

Register used services in your 'AppServiceProvider' (You can register your own services with `Service` class):

```
