includes/ignore.php

<?php
declare(strict_types=1);

require_once __DIR__ . '/core.php';

loadTranslations();

/*
|--------------------------------------------------------------------------
| Ignore admin tracking
|--------------------------------------------------------------------------
|
| Sets a cookie used to exclude the current browser from analytics.
| Useful for site owners, developers, and testers.
|
| The cookie domain is automatically derived from the first entry of
| The tracked sites list from settings.json and is shared across all its subdomains.
|
| Example:
|   breat.fr
|   code.breat.fr
|   blog.breat.fr
|
| All share the same brivacia_ignore cookie.
|
| Note:
| Cookies cannot be shared across different root domains.
|
*/

setcookie('brivacia_ignore', '1', [
    'expires' => time() + (brivacia_setting('admin.ignore_cookie_years', 5) * 365 * 24 * 3600),
    'path' => '/',
    'domain' => ignoreCookieDomain(),
    'secure' => true,
    'httponly' => false,
    'samesite' => 'Lax',
]);

echo t('ignore.enabled');