I am currently working on developing a solution for clients to comply with incoming GDPR regulations. Part of this task involves allowing users to explicitly opt-in and opt-out of cookies. I am using Cookie Consent for the general framework of displaying notices and allowing users to opt in/out but when it comes to actually developing code to implement that, I am stuck.
Google Analytics explicitly provides an opt-out function in the form of:
window[ga-disable-UA-XXXXXXXX-Y] = true;
However I have not been able to find ways to do this for other third-party cookies, such as Twitter and LinkedIn despite much googling. Twitter, for example, doesn't seem to offer anything similar to Google Analytics in the form of opt-out code; it seems like users need to log into their Twitter account and change settings through that, but on the sites I am working on Twitter is setting cookies because Twitter embeds are used on the site regardless of whether a visitor has an account or not.
The closest I have came to a solution is a suggestion to delete cookies by setting their expiry date in the past. However, AFAIK this won't stop cookies being set again. Also how then do I explicitly re-allow these cookies if the user decides to opt-in to allowing cookies in the future?