PHP code example of jamiecressey / php-mysql-session-handler

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

    

jamiecressey / php-mysql-session-handler example snippets

json
{
    "amiecressey/php-mysql-session-handler": "dev-master"
    }
}
bash
$ php composer.phar install
sh
handler = new \JamieCressey\SessionHandler\SessionHandler();

// Pass DB details to create a new MySQLi connection
$handler->setDbDetails('localhost', 'username', 'password', 'database');
// OR alternatively, inject an existing MySQLi resource
// $db = new Db(); // See: https://github.com/jamiecressey/php-mysql-pdo-database-class
// $handler->setDbConnection($db);

$handler->setDbConnection($db);
$handler->setDbTable('sessions');
session_set_save_handler($handler, true);
session_start();