存储在 SESSION 中的错误消息 [英] Error messages stored in SESSION

查看:56
本文介绍了存储在 SESSION 中的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SESSION 中存储错误消息是否是一个好习惯?例如在重定向之后.通过 url 传入对我来说不是一个解决方案......我想知道这是否是一个好的解决方案...因为...

Is it a good practice to store error messages in SESSION? For example after a redirect. Passing in through url isnt a solution for me... I am wondering if it is a good solution... because..

用户同时提交会导致问题吗?(一个很长的帖子,而ajax 内容是从另一个选项卡中获取的)可能会搞乱会话!或者这是不可能发生的?

Would a concurent submit of user cause problem? (A long time-taking post, while ajax content is obtained from another tab) that may mess up the session! Or that is impossible to happen?

如果用户发出请求但由于某种原因无法显示页面,则消息可能会显示在不相关的页面上!

If user makes a request and it fails for some reason to display the page then the message may be shown at an irrelevant page!

所以?任何替代品??
例如当使用 POST/redirected/get 模式时

So? Any alternatives??
For example when using POST/redirected/get pattern

推荐答案

在会话中存储错误消息时,必须注意,两个请求在显示之前不要覆盖另一个消息.而且您必须注意,应该显示消息的页面只显示自己的消息.

When storing error messages in the session, you must take care, that two request dont overwrite the other ones message, before it is displayed. And you must take care, that a page, that should display a message, only displays its own message.

您应该在错误发生时显示错误,而不是在之前重定向.在这种情况下也没有理由重定向.

You should show errors, when they occur and not redirect before. Also there is no reason to redirect in such a situation.

这篇关于存储在 SESSION 中的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆