skip to Main Content

So normally I have no problems with setting and unsetting cookies for my website. But for some reason I can’t delete this cookie that was set on my website by Google AdSense. Basically I was asking my users for consent, so I could show them ads. But I made a fatal mistake and I would like to ask the users again. But AdSense placed a cookie on my website called FCCDCF.

I use the following code to check for cookies and their value

if(isset($_COOKIE)) {
    var_dump($_COOKIE);
    foreach($_COOKIE as  $key => $val)
    {
        echo "cookie name: ".$key."<br /><br />Value: ".$val;
    }
}

This returns the following (I changed the the numbers/letters for safety)

cookie name: FCCDCF

Value: [null,null,null,["WJGBHDKJKNKSFAAEPA1326467585AkCBIAAgAUgQAgFIIAwAIFAAAAA42567869675425AAAAQQAAAAAIAAAAAAAAEAQ7567464563AAAAABAAAAAAAAAAAAAAAAAAAAgAA","1~","CP764359-1234-4321-1246-2SDFSDF34566"],null,null,[]]

Now I would normally think that I could easily delete this cookie by simply using setcookie("FCCDCF", "", time()-3600); – but this does not seem to be the case.

Apparently I do not know enough about cookies to find a solution for this. I have searched for hours now and tried a bunch of different solutions for deleting cookies for your website – but nothing worked so far.

My problem is that my mistake cost my 60% of my revenue for this particular site and if this does not get fixed, the website will close, because it’s an expensive website to keep running.

Thank you

EDIT with more details about the cookie and the code I’m using to get rid of it (also see image)

Cookie details:

Name: FCCDCF

Value: [null,null,null,["CPx4kYAPx4kYAEsACBDADWCgAAAAAEPAAAZQAAAQaQD2F2K2kKFgPi2QWYAQBCujIEAhUAAAAkCBIAAgAUgQAgFIIAwAIFAAAAAAAAAQEgCQAAQABAAAIACAAAAAAAIAAAAAAAQQAAAAAIAAAAAAAAEAQAAIAAQAAAAIAABEhCAAQQAEAAAAAAAQAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgAA","1~","34A656F2-7A38-4C75-88E5-06DDD813736B"],null,null,[]]

Domain: mydomain.com

Path: /

Expires / Max-Age: 2024-10-04T20:35:11.000Z

Size: 343

Priority: Medium

Important: I have tried to overwrite the cookie by creating a new one

I have tried to create a new cookie to see if this would automatically overwrite the current one. It doesn’t – it just creates a new cookie with the exact same name (see image further down). I created this cookie like this: setcookie("FCCDCF", "testcookie...", time() + (86400 * 30), "/");

So what code am I using to delete the cookies

First i simply tried this code: setcookie("FCCDCF", "", time() - (86400 * 30), "/"); – that didn’t work.

Next @ProfessorAbronsius asked me to set the cookie with the same value but with the time in the past which I did like this:

$CookieValue = $_COOKIE['FCCDCF'];
setcookie("FCCDCF", $CookieValue, time() - (86400 * 30), "/");

This is not working either. The cookie is still there. BUT it deletes the testcookie I set.

Image:
enter image description here

THANK you for your time

2

Answers


  1. There is a somewhat similar issue to this over here.

    The solution to delete the cookie provided in that post by Terry Burton is written in JavaScript and has a check to ensure the consent was given more than 12 months ago, but it may bring more insight as to how it should be done:

    <script>
      // Delete the Funding Choices cookie if consent is more than 12 months old
      try {
        const nm = "FCCDCF";        // Match name of Funding Choices cookie
        const dm = "mydomain.com";  // Match domain of Funding Choices cookie
        const pa = "/";             // Match path of Funding Choices cookie
        let tc = ('; ' + document.cookie).split('; ' + nm + '=');
        if (tc.length === 2) {
          tc = decodeURIComponent(tc.pop().split(';').shift());
          tc = JSON.parse(tc)[3][0].substring(1,9);
          tc = Uint8Array.from(window.atob(tc), (v) => v.charCodeAt(0));
          let dt = (tc[0] * 2**28) + (tc[1] * 2**20) + (tc[2] * 2**12) +
                   (tc[3] * 2**4)  + (tc[4] >> 4);
          if (Date.now() / 1000 - dt / 10 > 86400 * 365)
            document.cookie = nm + "=;path=" + pa + ";domain=" + dm +
                              ";expires=" + new Date(0).toUTCString();
        }
      } finally {}
    </script>>
    

    The idea is to create a new cookie with the exact same data (name, domain, path, etc) and set its expiry to the current time so that it gets deleted.

    If I am misunderstanding and you already have tried this, do make sure that there are no other cookies saved on the browser with the name "FCCDCF", as they may interfere with your attempt at deleting the one created by AdSense.

    Login or Signup to reply.
  2. I imagine you tried to delete it in Javascript :

    document.cookie = "FCCDCF=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
    

    And what happens when you Application > Cookies > right-click on site url > clear in the browser inspector ?

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search