I'm here after 2 hours of searching. All I found were older versions solutions
here is my code so far
<?php
$dir = __DIR__;
require($dir . '/src/XF.php');
XF::start($dir);
$app = XF::setupApp('XF\Pub\App');
echo "<pre>";
var_dump($app->session());
?>
The session contains the userId...