whitecube / laravel-cookie-consent Goto Github PK
View Code? Open in Web Editor NEWRegister, configure and ask for cookies consent in a EU-compliant way
License: MIT License
Register, configure and ask for cookies consent in a EU-compliant way
License: MIT License
Clicking 'Save settings' with deselected Analytics will still set Google Analytics cookies
I have just duplicated the folder the de folder and renamed it to sv for Swedish. I have translated the strings
` <?php
return [
'title' => 'Vi använder cookies',
'intro' => 'Denna webbplats använder cookies för att förbättra den övergripande användarupplevelsen.',
'link' => 'Ta en titt på vår Cookies-policy för mer information.',
'essentials' => 'Endast det väsentliga',
'all' => 'Acceptera alla',
'customize' => 'Anpassa',
'manage' => 'Hantera cookies',
'details' => [
'more' => 'Mer detaljer',
'less' => 'Mindre detaljer',
],
'save' => 'Spara inställningar',
'categories' => [
'essentials' => [
'title' => 'Väsentliga cookies',
'description' => 'Det finns vissa cookies som vi måste inkludera för att vissa webbsidor ska fungera. Därför kräver de inte ditt samtycke.',
],
'analytics' => [
'title' => 'Analyscookies',
'description' => 'Vi använder dessa för intern forskning om hur vi kan förbättra den tjänst vi tillhandahåller för alla våra användare. Dessa cookies bedömer hur du interagerar med vår webbplats.',
],
'optional' => [
'title' => 'Valfria cookies',
'description' => 'Dessa cookies aktiverar funktioner som kan förbättra din användarupplevelse, men deras frånvaro kommer inte påverka din förmåga att surfa på vår webbplats.',
],
],
'defaults' => [
'consent' => 'Används för att lagra användarens cookie-samtyckesinställningar.',
'session' => 'Används för att identifiera användarens webbläsarsession.',
'csrf' => 'Används för att säkra både användaren och vår webbplats mot CSRF-attacker (cross-site request forgery).',
'_ga' => 'Huvudcookie använd av Google Analytics, möjliggör en tjänst för att särskilja en besökare från en annan.',
'_ga_ID' => 'Används av Google Analytics för att behålla sessionstillståndet.',
'_gid' => 'Används av Google Analytics för att identifiera användaren.',
'_gat' => 'Används av Google Analytics för att reglera förfrågningstakten.',
],
];
`
but it doesn't work, I get cookieConsent::cookies.title instead of Vi använder cookies. I need help solving this as quickly as possible as my project is due to launch this week.
Hello,
I followed the discussion #36 and saw that v1.2.1 was released following this problem.
I followed the readme to add the module correctly, I checked in the DOM if @cookieconsentview embed the dom, it does, but unable to display it unless I remove all css and id classes. So, I'm trying to find out what I missed or did wrong?? Thanks for your help
Stack :
Laravel 9 (I use laravel-boilerplate as project base)
Bootstrap 5.3.3
VueJs 2.5.17
I'm currently having an issue with this library in a Laravel 10 application.
The issue is that on both Android and iOS accepting the cookie consent when my local development traffic is tunneled through Ngrok doesn't do anything, the consent box will not disappear.
I Might be missing something basic but i have updated to the latest version of the library 1.1.0
. I have tried changing the APP_URL
in my .env
file to the Ngrok domain i'm given and I've also tried updating the domain in the cookieconsent.php
file, nothing yet has fixed this.
The consent pop-up displays and closes as expected on my Windows and Linux desktop browsers when traffic is tunneled through Ngrok but the cookie is not set.
Steps to reproduce:
Any help or suggestions are much appreciated.
Yet it is possible to customize the button only to some extent.
I need to add tooltips and symbol instead of button text.
E.g.
@cookieconsentbutton(action: 'reset', label: '<i class="material-icons" style="font-size: 2em">shield</i>',
attributes: ['id' => 'reset-button', 'class' => 'btn fixed-bottom cookie-reset'],
btnattributes: ['class' => 'btn bg-transparent', 'style' => 'margin-left: 5px; margin-bottom:5px',
'data-toggle' => 'tooltip', 'title' => __('cookieConsent::cookies.manage')])
I added a pull request #42 for that.
Hope it finds a way to the main code. @toonvandenbos fell free to check and adapt, as you have better insight into the code.
Thanks for your work and support!
We're seeing issues in Sentry relating to the cookie consent.
TypeError
undefined is not an object (evaluating 'window.LaravelCookieConsent.acceptAll')
It's highlighting the following code as the issue.
<script data-cookie-consent>
{snip} function(e){e.preventDefault(),window.LaravelCookieConsent.acceptAll(),l()}(e)})),r.addEventListener("submit",(function(e){return function( {snip}
</script>
No easy possibility to change properties of class Whitecube\LaravelCookieConsen\Cookie
https://github.com/whitecube/laravel-cookie-consent#cookie-policy-details-page
$cookie->description is empty and cannot be easily set
Hi, I'm using Laravel 10+ and Inertia (React) SSR. The cookie consent dialog always shows up again on different pages other than the index
route. After I navigate to the home page, that's when the dialog never shows up again on different pages on the site. Am I missing some configs? Thanks
Hello,
even though APP_ENV is set to local, the cookie response gives a cookie with secure true.
When Varnish cache is running cookie consent keeps popping up on the home page and a couple of other pages, but not all pages.
Hello! I am a noob, so please don't blame me for the question:
How do I get my Policy Page (//mydomain/p/cookies-policy) in this:
'policy' => null,
I tried a lot like but have no idea what to do …
Adding an array I guess, but still no idea how to fill that.
Hellow, how do i add facebook pixel?
lp
Miha
Hi, I used the readme to integrate this cookie consent using laravel 10 (latest),
however, the app.blade.php
results in just printing @cookieconsentview instead of integrating it.
The package is included in vendors.
Someone knows what I'm doning wrong?
Kind regards, raymanP
@cookieconsentbutton('reset') opens modal, but clicking 'Only essentials' does not clear Google Analytics cookies. It only (re)sets the consent settings
README.md says this one
generate a button that will reset the user's cookies and show the consent modal again.
it is not now resetting cookies. Google Analytics cookies still in browser
this will not work with cookie encryption enabled, you need to add them to your cookieEncrypt middleware exceptions
Please update for laravel 11
Hello, this is a fantastic script for Laravel.
I use Google Tag Manager instead GA4 and dont't know how to create a custom code for this script.
Searched the manual and can't find anything.
¿How can I Use this type of code?
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
Thanks in advance
Thank you for the plugin; this is exactly what I was looking for for many weeks.
I encountered a minor issue in the view related to translation.
I had to make some code changes to make it work:"
+- line 37 :
From:
<span class="cookies__box">
<strong class="cookies__label">{{ $category->title }}</strong>
</span>
@if($category->description)
<p class="cookies__info">{{ $category->description }}</p>
@endif
To:
<span class="cookies__box">
<strong class="cookies__label">@lang('cookieConsent::cookies.categories.'.$category->key().'.title')</strong>
</span>
@if($category->description)
<p class="cookies__info">@lang('cookieConsent::cookies.categories.'.$category->key().'.description')</p>
@endif
The same issue also exists with the cookie description, but I haven't found a way to modify it yet...
+- line 48 :
<li class="cookies__cookie">
<p class="cookies__name">{{ $cookie->name }}</p>
<p class="cookies__duration">{{ \Carbon\CarbonInterval::minutes($cookie->duration)->cascade() }}</p>
@if($cookie->description)
<p class="cookies__description">{{ $cookie->description }}</p>
@endif
</li>
I have noticed scenarious where clicking on "Accept all" or "Accept essentials" will not work (popup box remains open). In such cases, users have to click a second time for the popup box to close.
This issue was the placement of @cookieconsentscripts - if there are other script tags of a larger size above it, the cookie box will open without the actual laravel-cookie-consent javascript being loaded, so clicking on it will throw an undefined error:
The solution is to move @cookieconsentscripts above all other script tags to ensure it loads first.
However, I would suggest displaying the popup box after the event DOMContentLoaded is fired
I would like to open an issue regarding to method that appears it doesn't exits.
Following instructions as mentioned in the documentation after I try to register the cookies into boot() method it throws error exception that the method accessibility() doesn't exits.
Laravel Version - 10.13.5
PHP Version - 8.2.7
Composer Version - 2.5.5
When I load a page on my website I get the popup for cookie consent. But when you click on any accept button no actual cookie is generated. But the strange part is if you select analytics the google analytics code is generated. So the code seems to be doing something.
It does seem to work on localhost, but not when deployed
I would like to have the option to add a nonce to the script tag without having to override classes.
I've tried overriding the CookiesManager getDefaultScriptTag
function to add a nonce, however for some reason I keep getting the $this->shouldDisplayNotice()
as true when the Cookie is in my Storage with 'consent_at' filled.
But when I make these changes in the vendor file, it's working.
Any ideas/suggestions?
I am using Laravel 10+, with a .test domain with SSL, When I try to 'accept all' or 'only essential' the cookie is NOT getting set. I followed the instructions carefully, am I missing something? When I refresh the page, the cookie consent dialog still shows up.
assume Google Analytics Google-Tag-ID=G-ABCDEF, then Google Analytics saves cookie _ga_ABCDEF
note "G-" is missing!
It works locally, but when I moved it to the server, I encountered this error:
script?id=e9923021dfd88a6e20c45479924cc61f:2 Mixed Content: The page at 'https://www.mydomain.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.mydomain.com/cookie-consent/accept-all'.
the accept-all and essentials are using content-type text/html. it's not inject any csrf token information in the call so the calls is redirected with a 302.
You need to add these endpoint to the csrf middleware exceptions list.
I hope this message finds you well. I am writing to report an issue I have encountered with the time calculation in the cookie notification feature.
When setting the time duration using the following code: ->duration(365 * 24 * 60)
the expected result should be exactly 1 year. However, the notification displays the time as "1 year, 1 month, 1 day," which is incorrect.
Expected Result:
The notification should display the time as "1 year."
Actual Result:
The notification displays the time as "1 year, 1 month, 1 day."
This discrepancy may confuse users and affects the accuracy of the information provided.
Hey,
I followed the documentation and configured everything but whenever I click 'Accept all' , or the other choices for the cookies it returns something like:
scripts: ["<script async src="https://www.googletagmanager.com/gtag/js?id=test"></script>",…]
status: "ok"
but later whenever I refresh the page, or just open another link from the menu it pops again the modal.
Anything where I may be wrong?
Does this work only if all external scripts has been loaded?
I can't seem to accept it if the site is still loading those external scripts from a certain ad network.
Hi - love this package by the way!
When recently testing my app locally using a non-seucre localhost alias (e.g. http://myapp.test
) I encountered a problem whereby consenting doesn't result in a cookie being set.
I believe this to be due to the consent cookie being forced to be secure: true
. This works fine in production, and it appears browsers allow it in localhost, but when using an alias through altering the hosts file etc, every time my page reloads it pops up as the consent cookie doesn't get set. Additionally, I think if people want their site to operate over http
for some reason, then this currently wouldn't work for them either.
I see two possible solutions; respecting config('session.secure')
(I think this should just require removing the explicit secure: true
here as the CookieJar
will use this setting by default), or setting secure: false
when the environment is local (or not production)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.