I'm having trouble using flashSession as well
I've added this to the (base) view: {{ flashSession.output() }}
But I can't get the flashSession flashes to show up. Flash direct works as it should.
TestController.php
public function logoutAction() {
$this->flashSession->success('Yay!');
$this->response->redirect('index');
}
services.php
$di = new FactoryDefault();
$di->set('config', function () use ($config) {
return $config;
});
$di->set('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
$di->set('db', function () use ($config) {
return new DbAdapter(array(
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname
));
});
$di->set('router', function() {
require __DIR__ . '/routes.php';
return $router;
});
$di->set('modelsMetadata', function () {
return new MetaDataAdapter();
});
$di->set('url', function () use ($config) {
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
}, true);
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_',
'prefix' => 'default'
));
return $volt;
},
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
));
return $view;
}, true);
$alerts = [
'success' => 'alert alert-success alert-dismissable fade in',
'notice' => 'alert alert-info alert-dismissable fade in',
'warning' => 'alert alert-warning alert-dismissable fade in',
'error' => 'alert alert-danger alert-dismissable fade in'
];
$di->set('flash', function() use ($alerts) {
return new \Phalcon\Flash\Direct($alerts);
});
$di->set('flashSession', function() use ($alerts) {
return new Phalcon\Flash\Session($alerts);
});