PHP code example of geggleto / session

1. Go to this page and download the library: Download geggleto/session library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

geggleto / session example snippets


//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");

//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
}