Close session early to avoid session lock blocking other scripts

This commit is contained in:
Dale Davies
2022-07-25 12:50:24 +01:00
parent f651b76aa2
commit c13445afa9
2 changed files with 4 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ abstract class AbstractAPI {
http_response_code(401);
die(json_encode(['error' => 'API token is incorrect or missing']));
}
// Close the session as soon as possible to avoid session lock blocking other scripts.
$this->session->close();
}
abstract protected function get_output(): string;

View File

@@ -45,6 +45,8 @@ abstract class AbstractPage {
if (!$csrfsection->offsetExists('token')){
$csrfsection->set('token', bin2hex(random_bytes(32)));
}
// Close the session as soon as possible to avoid session lock blocking other scripts.
$this->session->close();
}
abstract protected function render_content(): string;