Access LoginStatus variable from API Action

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
vuongduongquoc
User
Posts: 110

Access LoginStatus variable from API Action

Post by vuongduongquoc »

Hi all. Please help me. I have a global variable $LoginStatus in Page_Rendering. How can i access to this variable and pass it in API Action?

Code: Select all

function Page_Rendering()
{
    //Log("Page Rendering");
	global $LoginStatus;
	
	$LoginStatus= $LoginStatus["currentUserName"];

    //Log("Page Rendering");
}

Code: Select all

$app->get('/updatetaikhoansocai/{name}', function ($request, $response, $args) {
        $name = $args["name"] ?? null; // Get the input value
        if ($name !== null) {

		global $LoginStatus;
		ExecuteUpdate("UPDATE tbl_nks_employees set filtertaikhoan = '" . AdjustSql($name)."' where Username='".$LoginStatus . "'");

        }
        return $response; // Return Psr\Http\Message\ResponseInterface object 
 });

mobhar
User
Posts: 10083

Post by mobhar »

Are you using v2022? If so, please change:

ExecuteUpdate

to

ExecuteStatement

and try again.


arbei
User
Posts: 7014

Post by arbei »

vuongduongquoc wrote:

$LoginStatus= $LoginStatus["currentUserName"];

  1. This line overwrite the globl variable $LoginStatus.
  2. If you use Api_Action, you need to login the user yourself, you may use Route_Action instead so you may just use CurrentUserName().

Post Reply