diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 3cb1478f9..5b59f29db 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -45,6 +45,8 @@ abstract class Presenter extends Control implements Application\IPresenter FLASH_KEY = '_fid', DEFAULT_ACTION = 'default'; + const FLASH_SESSION_NAMESPACE = 'Nette.Application.Flash'; + /** @var int */ public $invalidLinkMode; @@ -1285,7 +1287,7 @@ public function popGlobalParameters($id) public function hasFlashSession() { return !empty($this->params[self::FLASH_KEY]) - && $this->getSession()->hasSection('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]); + && $this->getFlashSession()->hasSection(self::FLASH_SESSION_NAMESPACE); } @@ -1296,9 +1298,14 @@ public function hasFlashSession() public function getFlashSession() { if (empty($this->params[self::FLASH_KEY])) { - $this->params[self::FLASH_KEY] = Nette\Utils\Random::generate(4); + $this->params[self::FLASH_KEY] = Http\FlashSession::generateId(); + } + + if ($this->flashSession === NULL) { + $this->flashSession = new Http\FlashSession($this->params[self::FLASH_KEY], $this->session); } - return $this->getSession('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]); + + return $this->getSession(self::FLASH_SESSION_NAMESPACE); }