Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Seeker1337's avatar

Laravel 6+ Cookie consent package problems

Hello. I've installed the Cookie consent package following this guide:

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

I haven't touched anything after installing and just wanted to check out if it's working properly but nothing pops up after including it in a view file.

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

What could I possibly be doing wrong? Thanks for the help.

0 likes
11 replies
Nakov's avatar

@seeker1337 in the documentation it says

The package will not display the dialog when that cookie has been set.

So try clearing all the cookies/cache on your browser before testing if it works :)

Also a friendly reminder if an answer happen to help you you should mark the thread as resolved by selecting the reply as Best Answer, here for example: https://laracasts.com/discuss/channels/laravel/laravel-6-change-default-cookies-behavior?page=1#reply=561927 :)

Seeker1337's avatar

The problem is it doesn't set any cookies but still it won't display the message. The two cookies that get set upon visiting the website are the default ones. What I've specified in the Cookie consent doesn't get added neither the message displays.

1 like
Nakov's avatar
Nakov
Best Answer
Level 73

@seeker1337 I installed the package using this steps:

  • composer require spatie/laravel-cookie-consent

Published the config

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

And added in my welcome.blade.php file:

@include('cookieConsent::index')

And I got this result: https://imgur.com/ykmJY8N

Seeker1337's avatar

Oh, I've read that Optionally you can publish the config file and haven't done it. Now with that command it has worked out. Thank you very much.

EDIT: I would like to ask one more question related to this. Reading Laravel's cookie docs I saw this:

All cookies created by the Laravel framework are encrypted and signed with an authentication code, meaning they will be considered invalid if they have been changed by the client. To retrieve a cookie value from the request, use the cookie method on a Illuminate\Http\Request instance:

Is it the same if I'm using this package? I want to make sure if the cookies are changed by the client they'll be still considered invalid while using this package. Thank you mate.

Nakov's avatar

@seeker1337 happy to help :) make sure you accept the answer in the other thread as well, if that's what you ended up using

https://laracasts.com/discuss/channels/laravel/laravel-6-change-default-cookies-behavior?page=1#reply=561927

EDIT:

To answer to you question above, yes, Laravel cookies won't be changed. This package is just to ensure that the user is aware that there are cookies used. So if the client changes a cookie, for sure it will be invalid :)

Hope this helps.

2 likes
kocebs's avatar

hello, today i have problem :( how to fix this i used virtualbox 6 and ubuntu 18

with root: root@koce-VirtualBox:/var/www/html/MyProject# php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="config" Unable to locate publishable resources. Publishing complete.

with my user: koce@koce-VirtualBox:/var/www/html/MyProject$ php artisan vendor:publish --provider="Spatie\CookieConsent\CookieConsentServiceProvider" --tag="config" Unable to locate publishable resources. Publishing complete.

after add @include('cookieConsent::index'):

Facade\Ignition\Exceptions\ViewException No hint path defined for [cookieConsent]. (View: /var/www/html/MyProject/resources/views/welcome.blade.php) http://127.0.0.1:8000/

willeums's avatar

Have you tried typing php artisan vendor:publish in your console. Then selecting the appropriate number that corresponds to the vendor your're trying to publish?

Example: It will ask you which provider or tag you would like to publish.

[15] Provider: Spatie\CookieConsent\CookieConsentServiceProvider.

[16] Tag: cookie-consent-config.

...

1 like

Please or to participate in this conversation.