PHP code example of ronanchilvers / silex-sessions
1. Go to this page and download the library: Download ronanchilvers/silex-sessions 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/ */
// Set session variables
$app['session']->set('name', 'Fred Bloggs');
$app['session']->set('stuff', ['data' => 123]);
$app['session']->addFlash('notice', 'Yeehaa!');
// Get them out again
$name = $app['session']->get('name');
// With a default
$stuff = $app['session']->get('stuff', []);
// Get the flashes for a particular type
foreach ($app['session']->getFlashes('notice') as $message) {
echo "<p>Notice : {$message}</p>";
}