1. Go to this page and download the library: Download omatamix/session-lock 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/ */
omatamix / session-lock example snippets
use Omatamix\SessionLock\SessionManager;
// Construct a new session manager.
$session = new SessionManager();
$session->start();
if ($session->exists()) {
echo "The session is running!";
}
$session->put('hello', 'world');
if ($session->has('hello')) {
echo "The session variable exists.";
}
$session->delete('hello');
echo "Hello " . $session->get('hello') . "!";
echo "Hello " . $session->flash('hello') . "!";
$session->stop();
$session->regerate();
$session = new SessionManager([
'fingerprinting' => false,
]);
$session = new SessionManager([
'bind_ip_address' => false, // If set to true we will bind the ip address else dont.
'bind_user_agent' => false, // If set to true we will bind the user agent else dont.
]);
$session = new SessionManager([
'use_ip' => '127.0.0.1',
]);
use Omatamix\SessionLock\SessionHandlers\CacheSessionHandler;
$session = new SessionManager();
$session->setSaveHandler(new CacheSessionHandler(/** A `psr/cache` or `psr/simple-cache` pool. */));
use Defuse\Crypto\Key;
use Omatamix\SessionLock\Encryption\Adapter\Defuse;
use Omatamix\SessionLock\Encryption\Encrypted;
$session = new SessionManager();
$session->setSaveHandler(new Encrypeted(new CacheSessionHandler(/** A `psr/cache` or `psr/simple-cache` pool. */), new Defuse(Key::createNewRandomKey()));
// All session data will now be encrpyted using the `defuse` adapter.