Page 1 of 1

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

Posted: Tue May 30, 2023 11:58 pm
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?


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

Posted: Wed May 31, 2023 8:57 am
by arbei

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


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

Posted: Wed May 31, 2023 1:42 pm
by noorshiam

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


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

Posted: Wed May 31, 2023 5:22 pm
by mobhar

You may post your modification code for more discussion.


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

Posted: Thu Jun 01, 2023 11:03 am
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>";

?>

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

Posted: Thu Jun 01, 2023 11:14 am
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.


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

Posted: Thu Jun 01, 2023 6:10 pm
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.