1. Go to this page and download the library: Download amphp/http-server-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/ */
amphp / http-server-session example snippets
$session->get('key'); // will read data stored in key 'key'
// regenerate the client id
$session->regenerate();
// force read from storage
$session->read();
// rollback what is `set()` in the session but has not been commit()ed yet
$session->rollback();
// destroy the session
$session->destroy();
use Amp\Http\Server\Request;
use Amp\Http\Server\RequestHandler;
use Amp\Http\Server\Response;
use Amp\Http\Server\Session\Session;
class SomeRequestHandler implements RequestHandler
{
public function handleRequest(Request $request): Response
{
/** @var Session $session */
$session = $request->getAttribute(Session::class);
// any operations on the session
// return the response
}
}