PHP code example of wplibs / session
1. Go to this page and download the library: Download wplibs/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/ */
wplibs / session example snippets
use WPLibs\Session\WP_Session;
$session = new WP_Session('my_plugin_session', [
'lifetime' => 1440, // The session lifetime in minutes.
'expire_on_close' => false, // If true, the session immediately expire on the browser closing.
'cookie_name' => null,
]);
// Must call before the `init` hook.
$session->hooks();
// In some where:
$session['user_address'] = 'Some where';
// Retrive
dump($session['user_address']);