geggleto / session
Session Object Wrapper
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/geggleto/session
README
Object oriented wrapper around the super global _SESSION
Usage
//Make sure you are starting the session somewhere... session_start() $sessionContainer = new Session(); $session->flash("error", "My error"); //In your view on the next page $session->getFlash("error");
Helpers
If you are using Twig it might be helpful to just directly inject the error.
//Inject Error's into twig /** @var $session \Geggleto\Session */ $session = $c[Geggleto\Session::class]; // Grab from the container $error = $session->getFlash("error"); //Grab the message if (isset($error)) { $view->getEnvironment()->addGlobal("error", $error); //Inject it into twig as a global }