I’m using the PRG pattern to avoid multiple form submission. It has, however, a serious drawback — you cannot simply echo
the confirmation message to the user (obviously, the user won’t see the page, he will be redirected to another one).
What are the solutions to this problem? I know two of them, but none of them seems perfect.
- Use a custom redirect URL, like:
http://example.com/?msg=data-saved
. It’s stateless, so I think it’s quite reliable. But it creates problems when user copies the link, bookmarks it, etc. - Store a session variable/cookie, and check it on every page load. If it’s set, clear it and display the message. It seems OK, but I’m not sure about this one — it relies strongly on cookies, it’s a little more complicated.
Or maybe there are other ways I don’t know about? Some combination of sessions and URL parameters? I don't know.
What’s the best way in your opinion? Which one has the least drawbacks? What are the pros and cons?