42coders / eu-cookie-consent

MIT License
60 stars 17 forks source link

How to block cookies when not chosen #5

Closed rucky96 closed 3 years ago

rucky96 commented 3 years ago

I have installed this package in my laravel application.

I have added the following code to the "categories" array in "config.php":

            'functional' => [
                // Optional: The description defines the key in the translations for the category description
                'description' => 'functional_description',
                // In this array you can define all the Cookies you want to request form the User
                'cookies' => [
                    // The key defines the key in the translations and is used to access the Cookie specific information
                    'astuiriz_upv' => [
                        // Optional: you can set forced to make it impossible for the user to not accept this cookie.
                        // Optional: The description defines the key in the translations
                        // 'description' => 'key in translation File'
                    ],
                ],
            ],

However, it doesn't matter if I don't click on the banner checkbox or if I do, the "astuiriz_upv" cookie always appears. I check it in the Application> Cookies tab of my browser.

How can cookies be blocked using this package if the user does not click on the checkbox within the cookie banner?

Max-Hutschenreiter commented 3 years ago

You need to check if it's allowed to set the cookie.

if(EuCookieConsent::canIUse('astuiriz_upv')){ //setCookie }