PHP code example of renegare / silexcsh

1. Go to this page and download the library: Download renegare/silexcsh 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/ */

    

renegare / silexcsh example snippets




$app = new Silex\Application();

$app->register(new Renegare\SilexCSH\CookieSessionServiceProvider, [
    'session.cookie.options' => [
        'name' => 'CUSTOMNAME', // string
        'lifetime' => 0,        // int
        'path' => '/',          // string
        'domain' => null,       // string
        'secure' => false,      // boolean
        'httponly' => true      // boolean
    ]
]);

$app->get('/doing-nothing', function(Application $app) {
    return 'Nothing going on here with sessions';
});

$app->get('/persist', function(Application $app){
    $app['session']->set('message', 'Hello There!');
    return 'Check your cookie!';
});

$app->get('/read', function(Application $app){
    return print_r($app['session']->all(), true);
});

$app->get('/destroy', function(Application $app) {
    $app['session']->clear();
    return 'Ok Bye Bye!';
});