SessionFactory example

$sessionId = 'vqd4dpbtst3af0k4sdl18nebkn';
session_id($sessionId);
$sessionName = session_name();
$_COOKIE[$sessionName] = $sessionId;

$request = new Request();
$request->cookies->set($sessionName$sessionId);

$requestStack = new RequestStack();
$requestStack->push($request);

$sessionFactory = new SessionFactory($requestStacknew NativeSessionStorageFactory());

$container = new Container();
$container->set('request_stack', $requestStack);
$container->set('session_factory', $sessionFactory);

$listener = new SessionListener($container);

$kernel = new class($r) implements HttpKernelInterface {
    private Response $response;

    public function __construct(Response $response)
    {
$this->assertEmpty($_SESSION);
        $this->assertEmpty(session_id());
        $this->assertSame(\PHP_SESSION_NONE, session_status());
    }

    private function createListener(Request $request, SessionStorageFactoryInterface $sessionFactory)
    {
        $requestStack = new RequestStack();
        $request = new Request();
        $requestStack->push($request);

        $sessionFactory = new SessionFactory($requestStack$sessionFactory);

        $container = new Container();
        $container->set('request_stack', $requestStack);
        $container->set('session_factory', $sessionFactory);

        $listener = new SessionListener($container);

        return new SessionListener($container);
    }

    private function createValidSessionId(): string
    {
Home | Imprint | This part of the site doesn't use cookies.