Interesting… This works as expected…
if ($validation === 'success') {
$flash->add('success', 'Your account has been activated. Please log in.');
// TODO Look into why sleep(3) seems to be needed to post correct flash message - something to do with
// mimecast - browser sessions maybe?
sleep(3);
$this->sql->updateUser($userName);
} else {
$flash->add(
'error',
'Your account was not activated. Please try again or contact us with this error.'
);
}
return $response->withStatus(302)->withHeader('Location', '/');
Without sleep(3)
- the flash message posted to screen is for flash key ‘error’ even though updateUser()
has worked.
Notes:
sleep(1)
andsleep(2)
also posts the unexpected flash key ‘error’ message to UI.- more context:
/**
* @throws Exception
*/
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response
): ResponseInterface {
$flash = $this->session->getFlash();
$flash->clear();
...