<?php

namespace Lily\Middleware\Session;

class NativeStore
{
    public function get(array $request)
    {
        $request['session'] = $_SESSION;
        return $request;
    }

    public function set(array $response)
    {
        if (isset($response['session'])) {
            $_SESSION = $response['session'];
        }
        
        return $response;
    }
}

<?php

namespace Lily\Middleware\Session;

class NativeStore
{
    public function __construct()
    {
        if ( ! session_id()) {
            session_start();
        }
    }

    public function get(array $request)
    {
        $request['session'] = $_SESSION;
        return $request;
    }

    public function set(array $response)
    {
        if (isset($response['session'])) {
            $_SESSION = $response['session'];
        }
        
        return $response;
    }
}

Call session_start() if not already started
Call session_start() if not already started

This happens on construction although I could have opted to do it on demand.