PHP code example of detain / session-samurai

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

    

detain / session-samurai example snippets




$memcached = new \Memcached();  // create connection to memcached
$memcached->addServer('localhost', 11211);
$handler = new \Detain\SessionSamurai\MemcachedSessionHandler($memcached);
session_set_save_handler($handler, true);

$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$handler = new \Detain\SessionSamurai\RedisSessionHandler($redis);
session_set_save_handler($handler, true);