Use PHPMaker scripts in my existing website

Using https://discourse.hkvstore.com/t/use-phpmaker-scripts-in-my-existing-website-v2021/3735/1 only get -2 for userlevel and nothing for user id. what am i doing wrong

my code inside another folder.

<?php

namespace PHPMaker2021\demoapp;


$RELATIVE_PATH = "../testsite/";
require_once $RELATIVE_PATH."vendor/autoload.php";
require_once $RELATIVE_PATH."src/constants.php";
require_once $RELATIVE_PATH."src/config.php";
require_once $RELATIVE_PATH."src/phpfn.php";
require_once $RELATIVE_PATH."src/userfn.php";

echo CurrentUserID();
echo currentuserlevel();

?>

That is because in your script the session is not started. Be reminded that if you use this approach, the script is standalone, you need to do everything yourself. That’s why it is not recommended.