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?