1. Go to this page and download the library: Download seba1rx/sessionadmin 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/ */
seba1rx / sessionadmin example snippets
// App/MySession.php
namespace App;
use Seba1rx\SessionAdmin\SessionAdmin;
class MySession extends SessionAdmin
{
public function __construct()
{
$this->sessionName = 'my_app';
$this->sessionLifetime = 3600; // seconds
$this->keys = ['theme' => 'light']; // pre-seeded session keys
}
}
$session = new App\MySession();
$session->useAuthorization = false; // true for MPA URL enforcement
$session->activateSession(); // replaces session_start()
// On login:
$session->createUserSession($userId);
// On logout:
$session->terminate();
// Auth check:
if (!empty($_SESSION['sessionadmin']['isUser'])) {
// authenticated
}
$session = new App\MySession();
$session->setSessionHandler(new RedisSessionHandler($redis));
$session->activateSession();
use Seba1rx\TabManager\Bridge\SessionAdminBridge;
$session = new App\MySession();
$session->setTabHandler(new SessionAdminBridge());
$session->autoCleanupTabs = 30; // optional: remove tabs inactive for > 30 s
$session->activateSession();
// After the JS client has registered the tab:
$session->tabHandler->set('cart', ['apple' => 3]);
$cart = $session->tabHandler->get('cart');
$ready = $session->tabHandler->isTabIndexed(); // false until JS registers the tab