1. Go to this page and download the library: Download psr7-sessions/storageless 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/ */
psr7-sessions / storageless example snippets
use Lcobucci\JWT\Configuration as JwtConfig;
use Lcobucci\JWT\Signer;
use Lcobucci\JWT\Signer\Key\InMemory;
use PSR7Sessions\Storageless\Http\SessionMiddleware;
use PSR7Sessions\Storageless\Http\Configuration as StoragelessConfig;
$app = new \Mezzio\Application(/* ... */);
$app->pipe(new SessionMiddleware(
new StoragelessConfig(
JwtConfig::forSymmetricSigner(
new Signer\Hmac\Sha256(),
InMemory::base64Encoded('OpcMuKmoxkhzW0Y1iESpjWwL/D3UBdDauJOe742BJ5Q='), // replace this with a key of your own (see below)
)
)
));
use PSR7Sessions\Storageless\Http\SessionMiddleware;
use PSR7Sessions\Storageless\Http\Configuration as StoragelessConfig;
use PSR7Sessions\Storageless\Http\ClientFingerprint\Configuration as FingerprintConfig;
$app = new \Mezzio\Application(/* ... */);
$app->pipe(new SessionMiddleware(
(new StoragelessConfig(/* ... */))
->withClientFingerprintConfiguration(
FingerprintConfig::forIpAndUserAgent()
)
));
use Psr\Http\Message\ServerRequestInterface;
use PSR7Sessions\Storageless\Http\SessionMiddleware;
use PSR7Sessions\Storageless\Http\Configuration as StoragelessConfig;
use PSR7Sessions\Storageless\Http\ClientFingerprint\Configuration as FingerprintConfig;
use PSR7Sessions\Storageless\Http\ClientFingerprint\Source;
$app = new \Mezzio\Application(/* ... */);
$app->pipe(new SessionMiddleware(
(new StoragelessConfig(/* ... */))
->withClientFingerprintConfiguration(
FingerprintConfig::forSources(new class implements Source{
public function extractFrom(ServerRequestInterface $request): string
{
return $request->getHeaderLine('X-Real-IP');
}
})
)
));
sh
php -S localhost:9999 index.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.