I use this library: https://stackoverflow.com/a/37973763/1579327
If I request the page directly with the serverip it works but if I call the page via the domain it does not work. :/
I have installed mod_remoteip, so the server recognizes the real IP. I also have a PHP script, which gives me the "real" IP as a log (via $_SERVER['REMOTE_ADDR']). The IP that the server recognizes matches the exitnode IP, but why are Tor sessions not recognized by the domain? (The traffic goes through CLoudflare)
<?php
use Dapphp\TorUtils\TorDNSEL;
require_once 'src/TorDNSEL.php';
try {
$isTor = TorDNSEL::IpPort(
$_SERVER['SERVER_ADDR'],
$_SERVER['SERVER_PORT'],
$_SERVER['REMOTE_ADDR']
);
if ($isTor) {
echo '<script>window.sessionStorage.setItem("torsession", true)</script>';
}
} catch (\Exception $ex) {
echo $ex->getMessage() . "\n";
}
?>