1. Go to this page and download the library: Download ghostff/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/ */
ghostff / session example snippets
# Start session with default configurations.
$session = new Session();
$session->set('email', '[email protected]');
echo $session->get('email');
# use custom configuration file.
Session::setConfigurationFile('path/to/my/config.php');
# overriding specific configuration settings
Session::updateConfiguration([
Session::CONFIG_DRIVER => Redis::class,
Session::CONFIG_START_OPTIONS => [
Session::CONFIG_START_OPTIONS_SAVE_PATH => __DIR__ . '/tmp'
]
]);
# override a configuration for current session instance
$session = new Session([Session::CONFIG_ENCRYPT_DATA => true]);
# Start session with an auto generated id.
$session = new Session();
# Start session with custom ID
$session = new Session(null, bin2hex(random_bytes(32)));
$segment = $session->segment('my_segment');
echo $session->id();
# Opens, writes and closes session.
$session->commit();