如何确定是否由于 grails 中不接受 cookie 导致登录失败

发布于 2024-10-05 23:53:02 字数 290 浏览 0 评论 0原文

在我使用 shiro 的 grails 应用程序中,我使用 cookie 来存储会话数据(包括授权)。

当用户尝试在不接受 cookie 的情况下登录时,登录可以正常工作,但随后(如预期的那样)会话再次丢失并且用户被注销。

我一般不想改变这种行为,我只是想向用户显示一个通知,表明他的浏览器需要接受cookie。

那么有没有一种方法可以告诉该用户是在会话数据丢失后尝试登录的用户,以便我可以显示相应的消息?

我认为运行测试是否在每个页面上都接受 cookie 有点太多了,因此我只在登录时寻求解决方案。

In my grails application using shiro, I'm using cookies to store the session data including authorization.

When a user tries to log in without accepting cookies, the login works, but then (as expected) the session is lost again and the user is logged out.

I don't want to change this behavior in general, I just want to display a notification to the user that his Browser needs to accept cookies.

So is there a way to tell that this user has been the one who TRIED to log in after the session data is lost, so that I can display a respective message?

I think running a test whether cookies are accepted on every page is a bit too much, therefore I'm heading towards the solution at login only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情域 2024-10-12 23:53:02

您可以使用 grails 会话来存储用户的当前状态。然后,在登录时,检查 grails 会话并确定是否显示您的消息。

You could use the grails session to store the current state of the user. Then, on login, check the grails session and determine whether to show your message or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文