PHP code example of brace / mod-session

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

    

brace / mod-session example snippets


\Brace\Core\AppLoader::extend(function (\Brace\Core\BraceApp $app) {
    (/*.....*/)
    $app->setPipe([
        new \Brace\Session\SessionMiddleware(
            new \Brace\Session\Storages\FileSessionStorage("/tmp"), // replace this with your chosen storage type and connection string
            3600, // 1 hour ttl
            86400 // 1 day expiration time
        ),
        (/*.....*/)
    ]);
});

AppLoader::extend(function (BraceApp $app) {
    $app->router->on("GET@/", function() use ($app) {
        $session = $app->get(SessionMiddleware::SESSION_ATTRIBUTE);
        $session->set('foo', 'bar');
        (/*....*/)
        return $response;
    });
});