This topic is locked
[SOLVED]

Clear potential session variable when using master key.

8/20/2026 15:34:42
PHPRunner General questions
A
ayctech author

Hi, could you tell me how to clear the page when using MasterKey? I'm calling the "add" function from an external button, but the previous state remains if the process had already reached that point
img alt

img alt
.

1.png
2.png
ChatGPT 8/20/2026

To clear the page when using MasterKey in PHPRunner, especially after calling the "add" function from an external button, you can follow these general steps:

  1. Redirect After Process Completion: After the add function has been executed, you can use a redirect to clear the form. This can be done by adding a redirect script in the event that handles the external button click. You can use PHP to redirect to the same page or a different page.

    header("Location: yourpage.php");
    exit;

  2. Resetting Form Values: If you want to reset the form values when using the MasterKey, you can utilize JavaScript to reset the form fields. You can add an event listener to your button that resets the form fields when clicked.

    document.getElementById("yourButtonId").addEventListener("click", function() {
    document.getElementById("yourFormId").reset();
    });

  3. Using Session Variables: If the state is stored in session variables, make sure to clear those session variables after the add function completes. You can do this in your PHP script.

    session_start();
    unset($_SESSION['your_variable']);

  4. JavaScript to Clear Input Fields: If you are using JavaScript to handle the button click, you can add a function that clears all input fields on the form.

    function clearForm() {
    document.querySelector("form").reset();
    }

  5. Check for Error Handling: Make sure your error handling doesn’t keep the previous state. If an error occurs, ensure that you handle it properly and reset the form if necessary.


  6. Ensure Proper MasterKey Usage: Review your MasterKey settings to ensure that they are not retaining data unintentionally. Sometimes, settings might keep the previous data for a session.



If you are still facing issues, consider providing specific code snippets or additional details, and I can help you troubleshoot further.

Sergey Kornilov admin 8/20/2026

It is not quite easy to understand what exactly is the problem you are trying to solve. What does 'the previous state remains if the process had already reached that point' mean?

A
ayctech author 8/21/2026

I have three tables, using the master-list setup; when I reach the last one, the id_instituto and numero_registro load automatically. It works well, but to clear those fields, I have to click the "Add" button on the last table again. I would like to know how to clear the form so that the id_instituto and numero_registro can be loaded
img alt

img alt
.
It charges like this,
img alt

I need to know which variable I need to clear to get it to look like that; I call this form from elsewhere, and it loads everything because it starts from step 1 through step 3 (Image 1).

img alt

Sergey Kornilov admin 8/21/2026

Thank you, makes more sense.

To see which session variables are populated you can print them on the screen. You can something like this to BeforeProcess event of that Add page:
print_r($_SESSION);

A
ayctech author 8/21/2026

I cleared some variables, and it deleted the loaded data; what's needed now is to restore the state so that data can be loaded again.

unset($_SESSION["new_instituto_acreditado_masterkey1"]);
unset($_SESSION["new_instituto_acreditado_masterkey2"]);

unset($_SESSION["new_instituto_acreditado_especialidades_mastertable"]);
unset($_SESSION["new_instituto_acreditado_especialidades_masterkey1"]);
unset($_SESSION["new_instituto_acreditado_especialidades_masterkey2"]);

unset($_SESSION["new_instituto_acreditado_masterRecordData"]);

unset($_SESSION["new_instituto_acreditado_especialidades_search"]);
unset($_SESSION["new_instituto_acreditado_especialidades_pagenumber"]);

img alt

A
ayctech author 8/21/2026

I solved it this way, thanks.
session_start();

unset($_SESSION["new_instituto_acreditado_especialidades_mastertable"]);
unset($_SESSION["new_instituto_acreditado_especialidades_masterkey1"]);
unset($_SESSION["new_instituto_acreditado_especialidades_masterkey2"]);
unset($_SESSION["new_instituto_acreditado_especialidades_masterRecordData"]);

unset($_SESSION["new_instituto_acreditado_mastertable"]);
unset($_SESSION["new_instituto_acreditado_masterkey1"]);
unset($_SESSION["new_instituto_acreditado_masterkey2"]);
unset($_SESSION["new_instituto_acreditado_masterRecordData"]);

session_write_close();