Im using Zend Framework 3 and the SessionManager and im trying to build a controller plugin / view helper to display confirm dialogues after validating some Data . The idea was simply to set a Session variable with everything the confirm dialogue needs, reading it by the view, and unsetting it. But even this simple cycle fails. The plugin basically does this when invoked by the controller:
$dataArray = [
'some_data' => 'data'
];
$this->sessionManager->getStorage()->confirmDialog = $dataArray;
in the layout.phtml i call my view Helper which does this:
public function __invoke() {
$data = $this->sessionManager->getStorage()->confirmDialog;
$this->sessionManager->getStorage()->clear('confirmDialog');
return $this->getDialog($data);
}
I do inject the sessionManager to both the plugin and the view helper. When not clearing the variable after receiving its data i get the changed data from the session variable and it gets updated by the Plugin as it should.But when clearing the variable after the first time reading it, its always empty.
Here my global.php setup:
'session_manager' => [
'validators' => [
RemoteAddr::class,
HttpUserAgent::class,
]
],
'session_storage' => [
'type' => SessionArrayStorage::class
]