79111103

Date: 2024-10-21 17:18:46
Score: 0.5
Natty:
Report link

This is the solution that I ultimately went with:

const OTCookieName = 'OptanonConsent';

const OTCookieMatch = document.cookie.match(new RegExp('(^| )' + OTCookieName + '=([^;]+)'));
if (OTCookieMatch) {
    const OTCookieValue = OTCookieMatch[2];

    // replaxe C0003 with whatever OT value we need to check for
    if (OTCookieValue && OTCookieValue.includes('C0003')) {
        // user has opted-in
    }
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Darren Gates