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')) {
        function deleteCookie(name) {
            document.cookie = name + '=; Path=/; Domain=.youtube.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        var i = 0;
        for ( i=0; i< arr.length; i++){


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) {

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

So how can I do to delete a cookie ?


  • You have to ask this question to the plugin developer. – Max Yudin Jun 19 '18 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 Jun 19 '18 at 14:17
  • Domain=.youtube.com can be a source of problem for you I think :/ – Elex Jun 19 '18 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 Jun 19 '18 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 Jun 19 '18 at 14:40

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.

  • And for the cookies with another domain ? I don't find a solution to block them (particularly cookies from youtube.com). The only solution I found is to replace the youtube video_player div to another one and use the tarteaucitron.js plugin. But I can't touch to these videos beacause they are generated by Slider Revolution. – Jessy Jun 20 '18 at 7:07
  • If there are cookies from another domain in the browser cookies when viewing your site, then somewhere in your page/template/widget/plugin is sending a request to another site, and that request response is setting a cookie. You would see this with ads, for example. The only way to control other domains storing cookies on the browser when visiting your site is to remove the reqeust from that domain. You'll need to figure out what theme/plugin/whatever is making that request, and remove that request from the theme/plugin/whatever. – Rick Hellewell Jun 20 '18 at 16:44
  • What I have is a youtube video with autoplay, if I want to be compliant with gdpr I have to remove my video until the user accept the cookies ? – Jessy Jun 22 '18 at 13:08
  • IANAL (I am not a lawyer), but I don't think that video autoplay requires GDPR consent. Maybe to store the cookie. I use a 'we use cookies, accept if you want to continue using our site' GDPR notice. That is also in the site Privacy notice. But if the cookie is coming from youtube, then it is not your responsibility, IMHO (again, IANAL). – Rick Hellewell Jun 22 '18 at 17:01

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

  • For the youtube no cookie it's not gdpr friendly, the cookies are throw only if the user click on play to the video, but for my case (a video in autoplay for the homepage) I can't make this work, and even for all other video I have to block them if the user doesn't want to use the youtube cookies – Jessy Aug 9 '18 at 15:42
  • Hey @Jessy , why are saying www.youtube-nocookie.com is not GDPR friendly? It actually use no cookies even with autoplay active. I've just tested it on a website and worked just fine. Here are 2 printscreens looking for cookies, before and after replacing url ibb.co/hHNoy9 & ibb.co/khQVBU Have you tested yourself? – João Teixeira Aug 10 '18 at 8:36
  • I've tested on a wp site and when I click play on the video youtube throw me some cookies, look at the cookies in your domain name – Jessy Aug 10 '18 at 9:01
  • Nothing there @Jessy , I am afraid they can't send cookies from your domain unless you're using an API. – João Teixeira Aug 10 '18 at 14:20
  • That's strange, I'm only adding video with a content editor and even with the no-cookies link I have some cookies – Jessy Aug 10 '18 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.