To ensure that previously accepted non-essential cookies are no longer used following a refusal, you might choose to delete these cookies programmatically. This guide will explain how to do this.
The method described here presents a way to delete the cookies that are associated to the main domain and subdomains of the page in question.
⚠️ It is not technically possible to delete third-party cookies that have been dropped on the browser of a user who has previously accepted them.
The removal of cookies from the browser can be done thanks to a script that you can integrate in your website.
In order to set this configuration, follow these steps:
Identify the essential cookies
You have to identify the names of the necessary cookies that you want to keep on the user's browser. You will have to specify these cookies in the script in order not to delete them. The rest of the cookies, as well as the items stored in the localStorage, will be deleted by default.
⚠️ Do not delete Didomi's cookies (didomi_token and euconsent-v2).
This would mean that the consent notice would be displayed again to recollect consent.
Insert the script to delete the cookies
Follow the link below to access the script to insert:
https://github.com/didomi/samples/tree/main/how-to-delete-browser-cookies
This is not a universal recipe that can be applicable the same way in all cases. The script is a standard code that will potentially need to be adapted depending on the configuration and limitations of your particular case.
The script works on all browsers. It is triggered when a user who had previously agreed to everything changes their choices to refuse everything. In this sense, when a user withdraws their consent, the page will be automatically reloaded and all the cookies that have not been specified in the script will be deleted from the browser.