Fix session locking issue after refactoring routing

This commit is contained in:
Dale Davies
2022-07-19 12:27:20 +01:00
parent 2d0d7c89fb
commit 74c2fe882a
2 changed files with 9 additions and 8 deletions

View File

@@ -28,6 +28,12 @@ abstract class AbstractPage {
return urlencode($renderer($text));
}),
]);
// Get a Nette session section for CSRF data.
$csrfsection = $this->session->getSection('csrf');
// Create a new CSRF token within the section if one doesn't exist already.
if (!$csrfsection->offsetExists('token')){
$csrfsection->set('token', bin2hex(random_bytes(32)));
}
}
abstract protected function render_content(): string;