1. Go to this page and download the library: Download solophp/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/ */
solophp / session example snippets
use Solo\Session;
// Create session with default secure settings
$session = new Session();
// Store data
$session->set('user', $userData);
// Get data
$userData = $session->get('user');
// Check if data exists
if ($session->has('user')) {
// ...
}
// Remove data
$session->unset('user');
// Clear all data
$session->clear();
// Completely destroy session
$session->destroy();
// Check if session has expired
if ($session->isExpired()) {
// Handle expired session
}
// Get last activity timestamp
$lastActivity = $session->getLastActivity();
// Get value with default fallback
$value = $session->get('key', 'default');
// Set value
$session->set('key', 'value');
// Check existence
$exists = $session->has('key');
// Remove specific key
$session->unset('key');
// Get all session data
$allData = $session->all();
// Clear all data
$session->clear();
// Regenerate session ID
$session->regenerateId();
// Destroy session completely
$session->destroy();
// Get current session ID
$id = $session->getCurrentId();
// Get session cookie name
$name = $session->getCookieName();
// Get session save path
$path = $session->getSavePath();
// Get session status
$status = $session->getStatus();
// Get configured timeout
$timeout = $session->getTimeout();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.