odan / session

A middleware oriented session handler for PHP and Slim 4+
https://odan.github.io/session/
MIT License
56 stars 11 forks source link

Flash messages not preserved after redirection #10

Closed lewweiming closed 4 years ago

lewweiming commented 4 years ago
## form_endpoint.php

$flash = $session->getFlash();
$flash->set('data', [
'test' => true
]);

header('Location: ' . $_SERVER['HTTP_REFERER']);

The flash data is empty after redirection. Did I miss out something?

odan commented 4 years ago

To commit the session use the save method:

// ...
$flash = $session->getFlash();
$flash->set('data', [
'test' => true
]);

$session->save();

header('Location: ' . $_SERVER['HTTP_REFERER']);