PHP code example of phpnomad / privacy
1. Go to this page and download the library: Download phpnomad/privacy library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpnomad / privacy example snippets
namespace MyApp\Strategies;
use PHPNomad\Privacy\Interfaces\TrackingPermissionStrategy;
class CookieConsentTrackingStrategy implements TrackingPermissionStrategy
{
public function canTrack(): bool
{
return isset($_COOKIE['consent']) && $_COOKIE['consent'] === 'accepted';
}
}
namespace MyApp;
use MyApp\Strategies\CookieConsentTrackingStrategy;
use PHPNomad\Loader\Interfaces\HasClassDefinitions;
use PHPNomad\Privacy\Interfaces\TrackingPermissionStrategy;
class AppInitializer implements HasClassDefinitions
{
public function getClassDefinitions(): array
{
return [
CookieConsentTrackingStrategy::class => TrackingPermissionStrategy::class,
];
}
}