admin管理员组

文章数量:1122826

First sorry for my bad english, i'm french. I need to make my website GDPR Friendly, so for this I use the plugin 'RGPD' who give me the possibility to check or uncheck multiples types of cookies. This plugin also give some functions to use.

Here is what I try :

  if (!is_allowed_cookie('_ga')) {
    ?>
    <script>
        function deleteCookie(name) {
            document.cookie = name + '=; Path=/; Domain=.youtube; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        }
        var arr = ["GPS","APISID","CONSENT","HSID","LOGIN_INFO","PREF","SAPISID","SSID","VISITOR_INFO1_LIVE","YSC"];
        var i = 0;
        for ( i=0; i< arr.length; i++){
            deleteCookie(arr[i],false,-1);
        }

    </script>
    <?php
}

But no one of the cookies are deleted, or maybe they are, but they came back instantly after. I also try this method in PHP :

 foreach($_COOKIE as $key => $value) {
        unset($_COOKIE[$key]);
    }

but nothing too, no one of the cookies was deleted.

So how can I do to delete a cookie ?

Thanks.

First sorry for my bad english, i'm french. I need to make my website GDPR Friendly, so for this I use the plugin 'RGPD' who give me the possibility to check or uncheck multiples types of cookies. This plugin also give some functions to use.

Here is what I try :

  if (!is_allowed_cookie('_ga')) {
    ?>
    <script>
        function deleteCookie(name) {
            document.cookie = name + '=; Path=/; Domain=.youtube.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        }
        var arr = ["GPS","APISID","CONSENT","HSID","LOGIN_INFO","PREF","SAPISID","SSID","VISITOR_INFO1_LIVE","YSC"];
        var i = 0;
        for ( i=0; i< arr.length; i++){
            deleteCookie(arr[i],false,-1);
        }

    </script>
    <?php
}

But no one of the cookies are deleted, or maybe they are, but they came back instantly after. I also try this method in PHP :

 foreach($_COOKIE as $key => $value) {
        unset($_COOKIE[$key]);
    }

but nothing too, no one of the cookies was deleted.

So how can I do to delete a cookie ?

Thanks.

Share Improve this question asked Jun 19, 2018 at 13:45 JessyJessy 1172 silver badges6 bronze badges 6
  • You have to ask this question to the plugin developer. – Max Yudin Commented Jun 19, 2018 at 14:10
  • The only thing that came from the plugin is "!is_allowed_cookie('_ga')" and this work, it only check if the cookie _ga is checked or not by the user, that's the script in javascript who don't work – Jessy Commented Jun 19, 2018 at 14:17
  • Domain=.youtube.com can be a source of problem for you I think :/ – Elex Commented Jun 19, 2018 at 14:25
  • Yes, that was for testing removing all the cookies from youtube (all the cookies in the arr have the youtube.com domain) – Jessy Commented Jun 19, 2018 at 14:32
  • Why this is so hard to make a website gdpr compliant, i only can remove cookies from google analytics thanks to their function 'ga-disable-X_XXX_X', but for all other cookies i search a solution for two days now and still nothing – Jessy Commented Jun 19, 2018 at 14:40
 |  Show 1 more comment

2 Answers 2

Reset to default 0

You can delete all cookies that belong to your domain. See the answer to this here: https://stackoverflow.com/questions/2310558/how-to-delete-all-cookies-of-my-website-in-php .

You would have to build a form with a button to that (on submit) would call the function that deleted the cookies that belong to your domain. I don't think you can delete cookies that don't belong to your domain.

I am currently also trying to configure this plugin to block cookies not allowed by users. So I am will keep an eye on this thread hoping someone will enlighten our path.

I also saw people around worried about 3rd party cookies like youtube. I know a trick that may help some folks:

SOLUTION: youtube.com allows us to embed videos with extended privacy functionality. All you have to do is replace youtube.com with youtube-nocookie.com

FOR EXAMPLE: instead of src="https://www.youtube.com/embed/videourl" just use src="https://www.youtube-nocookie.com/embed/videourl"

From now on to embed new videos you can also go to Youtube's video you want to embed select “Embed Options” and check the box “Enable privacy-enhanced mode.” This has gives you exactly what I described above: youtube-nocookie.com instead of youtube.com

本文标签: pluginsWordpress delete cookie