duanfei7508 2014-10-07 21:23
浏览 19

创建可靠的Flash / Feedback消息系统

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?

  • 写回答

1条回答 默认 最新

  • duan2891 2014-10-08 14:56
    关注

    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)

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。