Alternative Error Message To "The Following Global Variables are Missing"

Under some cases, global variables will be missing after a customer has logged out (ex: he opens 2 windows), or under a variety of other circumstances, such as bookmarking a URL and going back to it later without any of the previous globals set.

How can I create a custom page or text for when this happens? At the very least, I’d like a custom header.

Thanks!

If global variables are missing you have simply an error in your application which needs to be solved. I always advise to allocate the globals on a central spot, i.e. the logon page. Then you will never run into issues like these.

Agreed, but what if someone has 2 windows open and logs out from a different page? Or bookmarks an internal page?
Your solution is good, but won’t cover those cases. As silly as it is, you can image novice users bookmarking a page and then going back to it, seeing the error, and panicking.

You can consider to use a small piece of code in the onscriptinit to sc_redir to the main page if you main global is not allocated or has the wrong value.

I have the same issue but this happens when an application is kept idle for sometime where the session has expired. Here are the steps to undrerstand what is happening

  1. Keep the running application idle until the session expires
  2. Now click on any menu and where the application uses the global variable
  3. See the below, I clicked one link after the session expired and I am getting the error saying the below global variables are not found. When I log off from my application and login back then this error goes away
  4. I tried the below script in the onApplicationInit event but that script has not executed at all since I did not get any echo message

if ( !isset([society_id]) )
{
echo ‘Session Expired. Please logoff and login back’;
}
else
{
echo ‘Else’;
}
Your help here how to detect this scenario and show an appropriate message to the user will be highly helpful.

Thank you

anyone found a solution yet for this?

Aducom, Looks like this message fires before onscriptinit. I am setting global variable in the Login screen and in one of the screen I have used the below under onscriptinit event

if (is_null([usr_id]) || empty([usr_id]))
{
echo ‘Null or empty’;
sc_redir(login.php);
}

But this code is not getting executed I am still getting the message

[SIZE=4]The following global variables are missing:[/SIZE] usr_id;

If a user logs out then a few globals are destroyed, one of it is usr_id. That’s in your (generated) logon procedure. If anything happens elsewhere in your application you get this message. I think that if you change the destroy and just erase the data then you should not get this error any more. But in your case I would not use is_null, which is a value, but isset which checks if the variable exists.

I have even used isset but that also not working

hello,
rather try this;

///quote+

[usr_id] = NULL;
if (is_null([usr_id])) {
[usr_id] = "Null or empty "; //define to suit
echo [usr_id];
sc_redir(login.php);
}
else
{
echo [usr_id];
}

////unquote ++