How to display messages to the user after a POST + HTTP redirect

后端 未结 6 1968
执念已碎
执念已碎 2020-12-08 10:52

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 (

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 11:44

    If you don't want to rely on sessions for whatever reason you could use a Get variable / custom url and then if that variable is present, check the refer. If the refer is proper, then display the message. Yes, this adds reliance on refers being sent in order to show the confirmation message, but otherwise you're relying on sessions (which while reliable, aren't 100% perfect for all solutions either.)

    And honestly, some large sites that are normally pretty good about this kind of thing just stick a "actiondone=true" in the url. (I've noticed Facebook does it in some places.)

提交回复
热议问题