1. Go to this page and download the library: Download upscale/swoole-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/ */
upscale / swoole-session example snippets
use Upscale\Swoole\Session\SessionDecorator;
$server = new \Swoole\Http\Server('127.0.0.1', 8080);
$server->set([
// Disable coroutines to safely access $_SESSION
'enable_coroutine' => false,
]);
$server->on('request', new SessionDecorator(function ($request, $response) {
$_SESSION['data'] ??= rand();
$response->end($_SESSION['data']);
}));
$server->start();