Access LoginStatus variable from API Action

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?

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

    //Log("Page Rendering");
}



$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 
 });

Are you using v2022? If so, please change:

ExecuteUpdate

to

ExecuteStatementand try again.

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().