Struggling with data that is not persisted to the next request.
Using Slim 4 and odan\session 6.
I’m adding session middleware to every route/request, in routes.php:
$sessionMiddleware = new SessionStartMiddleware(
new PhpSession($sessionSettings['options'])
);
$myRoute->add($sessionMiddleware);
$myOtherRoute->add($sessionMiddleware);
Added it in the container:
PhpSession::class => DI\create()->constructor($settings['session']['options']),
So I can get it injected in my controller using the constructor:
public function __construct(
private PhpSession $session,
) {}
Everything works. Except the data i save to the session is not showing up in a next request. Just an empty PhpSession()
:
$this = {\App\Auth\AuthMiddleWare}
session = {Odan\Session\PhpSession}
storage = {array[0]}
flash = {Odan\Session\Flash}
storage = {array[0]}
storageKey = "_flash"
options = {array[8]}
id = null
name = "app"
lifetime = {int} 29030400
path = null
domain = null
secure = false
httponly = true
cache_limiter = "nocache"
It’s not setting the ‘id’, is that maybe the problem?