There are many threads talking about how to implement simple user feedback/flash messages system to report information back to the users, like "invalid password", "settings saved", "new thread posted" and so on. It is fairly simple using
$_SESSION['message'] = "feedback message";
And then retrieving that session key on the next, redirected page. However, consider this scenario: the user submits a new thread to website.com/philosophy, but he failed the captcha and after the form is processed it saves
$_SESSION['message'] = "Invalid captcha";
And begins to redirect the user back to website.com/philosophy where he was trying to post from. Now, imagine that the server or his connection lags a little during this redirection, and the user meanwhile opens website.com/philosophy on another browser TAB. Now the "invalid captcha" would be shown there, when it should be only shown on the tab working the redirection.
How can you reliably display the message only when it is a match from its original redirection page?
Given the lack of answers, I'll say the best idea I could come up with.
I will make the flash message both time based and page based, rather than simply page based.
In this case, if a user is making a new thread at website.com/philosophy, and he refreshes multiple website.com/philosophy screens, he will get the message saying on all of them rather than just 1, for a short valid period, and can even stack messages so if he tried to post twice from website.com/philosophy and both failed, he'd get two messages that two post attemps failed, rather than risking having the messages actually be swaped for the different posts (which can happen if the first message's redirection took longer than the second message redirection)