Quantcast
Channel: How to detect users setting do-not-track - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by miken32 for How to detect users setting do-not-track

$
0
0

It's sent as an HTTP header:

function dnt_enabled()
{
   return (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == 1);
}

if dnt_enabled() {
    // do stuff...
}

Or, if you're using PHP 7:

function dnt_enabled(): bool
{
   return (bool)$_SERVER['HTTP_DNT'] ?? false;
}

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>