We will do the same thing we did in the past:
- Extract a seed for each user, store it in a cookie we persist for 60 days
- Based on that and sampling configuration, decide if we need to set the PHP_ENGINE cookie to a specific value and store it for a week,
- Check with every request if the PHP_ENGINE cookie should be reset
See a past implementation here https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikimediaEvents/+/508172/5/modules/all/ext.wikimediaEvents.php7.js