1. Go to this page and download the library: Download popphp/pop-session 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/ */
use Pop\Session\Session;
$sess = Session::getInstance();
echo $sess->getId();
echo $sess->getName();
$sess->regenerateId(); // pass false to keep the old session's data instead of deleting it
use Pop\Session\SessionNamespace;
$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->foo = 'bar';
if (isset($sessMyApp->foo)) {
echo $sessMyApp->foo; // Only available under the namespace.
} else {
echo 'Nope!';
}
use Pop\Session\SessionNamespace;
$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->setTimedValue('foo', 'bar', 10); // # of seconds
$sessMyApp->setRequestValue('foo', 'bar', 1); // # of requests
use Pop\Session\SessionNamespace;
$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->kill(); // only removes the 'MyApp' namespace's data
$sessMyApp->kill(true); // destroys the whole session, same as Session::getInstance()->kill()