PHP code example of hichxm / session-manager-database

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

    

hichxm / session-manager-database example snippets


$session_method = new DATABASE_SessionManager([
    "type" => "mysql", //Type of your database
    "name" => "sessionmanager", //Name of your database
    "server" => "127.0.0.1", //Host
    "port" => 3306, //Port
    "username" => "root", //Username
    "password" => "" //Password
]);
$session = new SessionManager($session_method);

//Start session.
$session->start();

//Set data or different method to set data.
$session->set($key = "id", $value = "1545348");
$session['id'] = 1545348;

//Get data or different method to get data.
$session->get($key = "id");
$session['id'];

//Unset data.
$session->unset($key = "id");
unset($session['id']);

//Stop session.
$session->stop();