Why this matters
Tracking requires prior, informed consent in many jurisdictions.
Only set analytics/marketing cookies if consent.purposes.analytics === true and consent.version matches current policy; re-check on version bump. (GDPR Art. 7, ePrivacy)
Tracking requires prior, informed consent in many jurisdictions.
Side-by-side examples engineers can pattern-match during review.
res.cookie('ga', token, { httpOnly:false }); // set unconditionallyapp.use((req,res,next)=>{
const c = req.consent;
if(c?.purposes?.analytics === true && c.version === CURRENT_POLICY){
res.cookie('ga', token, { sameSite:'Lax' });
}
next();
});if(consent.purposes.analytics) setAnalyticsCookie();setAnalyticsCookie(); // ignoring consentFrom the same buckets as this rule.