diff --git a/src/Core/View.php b/src/Core/View.php index 1736420..9b9d8a6 100755 --- a/src/Core/View.php +++ b/src/Core/View.php @@ -10,6 +10,7 @@ class View private string $layout = 'main'; private array $data = []; private Security $security; + private ?string $csrfTokenCache = null; public function __construct(Security $security) { @@ -80,7 +81,10 @@ class View public function csrfToken(): string { - return $this->security->generateCSRFToken(); + if ($this->csrfTokenCache === null) { + $this->csrfTokenCache = $this->security->generateCSRFToken(); + } + return $this->csrfTokenCache; } public function csrfField(): string