PHPackages                             pascalkrieger/laravel-cookie-consent - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. pascalkrieger/laravel-cookie-consent

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

pascalkrieger/laravel-cookie-consent
====================================

Allow/disallow types of cookies in your Laravel Application

v1.0.0(3y ago)022MITBlade

Since Feb 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/PascalKrieger/laravel-cookie-consent)[ Packagist](https://packagist.org/packages/pascalkrieger/laravel-cookie-consent)[ RSS](/packages/pascalkrieger-laravel-cookie-consent/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Cookie Consent
======================

[](#laravel-cookie-consent)

This package currently work in progress.

The package provides the views and controllers necessary to display a fixed message at the bottom of the window, prompting the user to accept the cookies or configure them.

If the user chooses to configure the cookies a modal will be displayed listing all types of cookies the website uses, allowing to disable or enable certain types. Once his preferences are saved a button is displayed enabling the user to configure his preferences.

The views are styled with tailwindcss and alpinejs leverages the rest, so these are prerequisite in your Laravel project.

Once the preferences are saved, you can check in your views if a certain type of cookies is allowed like this:

```
@if(session('cookie-config.Functional'))
    //Your code, maybe a Google Analytics tag
@endif
```

Where `Functional` corresponds to one of the `type` values in the cookies array of your config file.

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

[](#installation)

This package is intended for use in existing Laravel projects using Tailwindcss and AlpineJS.

You can install the package via composer:

```
composer require pascalkrieger/laravel-cookie-consent
```

Tailwindcss and AlpineJS should be installed, if not install them following the instructions in their documentation.

For Tailwindcss visit:

For AlpineJS visit:

Publish the views running:

```
php artisan vendor:publish --provider="Pascalkrieger\LaravelCookieConsent\LaravelCookieConsentServiceProvider" --tag="laravel-cookie-consent-views"
```

Then run:

```
npm run build
```

Usage
-----

[](#usage)

Include the blade component at the bottom of your page or layout:

```

```

You should publish and edit the config file, run this command:

```
    php artisan vendor:publish --provider="Pascalkrieger\LaravelCookieConsent\LaravelCookieConsentServiceProvider" --tag="laravel-cookie-consent-config"
```

The code is pretty basic and self explanatory. As stated before this is work in progress, in use right now in some of my other projects. You´re welcome to use it as you wish.

Localization
------------

[](#localization)

The package currently ships with translations for English and Spanish. you can easily add more languages, first publish the packages lang folder with:

```
    php artisan vendor:publish --provider="Pascalkrieger\LaravelCookieConsent\LaravelCookieConsentServiceProvider" --tag="laravel-cookie-consent-lang"
```

Add a folder to `lang/vendor/laravel-cookie-consent` with your language code, for example `lang/vendor/laravel-cookie-consent/de`, and place a `text.php` file with the following contents within it:

```
// lang/vendor/laravel-cookie-consent/de/text.php
