PHP code example of ellipse / session-handler

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

    

ellipse / session-handler example snippets




namespace App;

use Cache\Adapter\Predis\PredisCachePool;
use Cache\SessionHandler\Psr6SessionHandler;

use Ellipse\Session\SetSessionHandlerMiddleware;

// Get an implementation of php SessionHandlerInterface. Here a session handler
// managing data with redis is used.
$client = new \Predis\Client(...);

$pool = PredisCachePool($client);

$config = ['ttl'=>3600, 'prefix'=>'foobar'];

$handler = new Psr6SessionHandler($pool, $config);

// This middleware will set $handler as the session handler. Obviously it should
// be processed before any call to session_start().
$middleware = new SetSessionHandlerMiddleware($handler);