How to get CurrentUserID from Custom Files with Include Common Files disabled (v2021)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
noorshiam
User
Posts: 67
Location: Surabaya - East Java - Indonesia
Contact:

How to get CurrentUserID from Custom Files with Include Common Files disabled (v2021)

Post by noorshiam »

Hi all ...

I'm trying to create custom file with Include Common Files disabled, and here my code :

<?php
namespace PHPMaker2021\fotoang;
use PHPMaker2021\fotoang\{UserProfile, Language, AdvancedSecurity, Timer, HttpErrorHandler};

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

echo "CurrentUserID() = " . CurrentUserID() . "<br>";

?>

And I got nothing.
Can I use built in PHPMaker function, like CurrentUserID, CurrentUserName in Custom files with Include Common Files disabled?


arbei
User
Posts: 9292

Post by arbei »

You have not started the session yet. You may refer to the generated index.php and see how to start session.


noorshiam
User
Posts: 67
Location: Surabaya - East Java - Indonesia
Contact:

Post by noorshiam »

I have started the session and got 404 error , Route fotoajm/testing.php not found


mobhar
User
Posts: 11660

Post by mobhar »

You may post your modification code for more discussion.


noorshiam
User
Posts: 67
Location: Surabaya - East Java - Indonesia
Contact:

Post by noorshiam »

this is my code :

<?php
namespace PHPMaker2021\fotoang;

use PHPMaker2021\fotoang\{UserProfile, Language, AdvancedSecurity, Timer, HttpErrorHandler};
// use ... (omitted)

// Relative path
$RELATIVE_PATH = "";

// Require files
require_once "vendor/autoload.php";
require_once "src/constants.php";
require_once "src/config.php";
require_once "src/phpfn.php";
require_once "src/userfn.php";

// original code in the index.php (omitted)

// Run app
$app->run();

echo "CurrentUserID() = " . CurrentUserID() . "<br>";
//echo "CurrentUserID() = " . CurrentUserName() . "<br>";
$usernow = CurrentUserID();
echo "CurrentUserID() = " . $usernow . "<br><br>";

?>

mobhar
User
Posts: 11660

Post by mobhar »

noorshiam wrote:

got 404 error , Route fotoajm/testing.php not found

Since v2021, there is no need to call the filename in URL. Try to just call testing instead of testing.php.


arbei
User
Posts: 9292

Post by arbei »

Your code (trying to insert your own code after the original code in the index.php) will not work. The PHP framework doesn't work like what you thought.

If you don't know how to start session, read session_start.


Post Reply