Since PSR7Session depends on lcobucci/jwt, lcobucci/clock, and dflydev/fig-cookies, you need to require them as well, since with this sort of setup you are explicitly using those components:
It looks like the psr7-sessions/storageless is sending only a cookie when you access the LazySession instance via HTTPS. Example:
The custom Session middleware
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use PSR7Sessions\Storageless\Http\SessionMiddleware;
class MiddlewareInvokableClass implements MiddlewareInterface
{
/**
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$privateKey = file_get_contents(__DIR__ . '/../resources/keys/private_key.pem');
$publicKey = file_get_contents(__DIR__ . '/../resources/keys/public_key.pem');
$session = SessionMiddleware::fromAsymmetricKeyDefaults($privateKey, $publicKey, 1200 * 10);
return $session->process($request, $handler);
}
}
Add the middleware:
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use PSR7Sessions\Storageless\Http\SessionMiddleware;
use Slim\Factory\AppFactory;
require_once __DIR__ . '/../vendor/autoload.php';
$app = AppFactory::create();
$app->addRoutingMiddleware();
$app->add(new MiddlewareInvokableClass());
// This works too
// $app->add(SessionMiddleware::fromAsymmetricKeyDefaults($privateKey, $publicKey, 1200));
$app->addErrorMiddleware(true, true, true);