身份cookie到期 [英] Identity cookie expiry

查看:93
本文介绍了身份cookie到期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的身份cookie过期时间为"ExpireTimeSpan",我将如何自动重定向到登录页面?我确实知道有一个事件"OnRedirectToLogin",但是除非请求通过,否则不会触发该事件.有没有办法,我可以在Cookie过期后立即重定向到登录,而不是继续发送请求以确认其超时?

How would I redirect to login page AUTOMATICALLY, if my Identity cookie has expired at "ExpireTimeSpan" value? I do understand there is an event "OnRedirectToLogin" but that doesn't get triggered unless a request comes through. Is there a way, I can redirect to login right after the cookie has expired rather than keep sending requests to verify it has timed out?

推荐答案

除非引起我的误解,否则您想要的是服务器与客户端的连接,但是标准的客户端/服务器HTTP可以采用其他方法.客户端应该向服务器发送请求,并且如果它的身份验证cookie已过期,则可以在某个时候进行重定向,但是如果cookie过期并且客户端再也不需要向服务器询问任何其他信息,则不必告诉任何事情已经过期.服务器可以通过多种方式来通知客户端,以另一种方式进行通信,但必须保留以用于非常特殊的需求.您确定需要吗?

Unless I misunderstand, what you want is the server to reach out to the client, but standard client/server HTTP works the other way around. The client is supposed to send requests to the server, and at some point to get redirected if its authentication cookie has expired, but if the cookie expires and the client never ask the server for anything more ever, then it doesn't have to be told anything has expired. Communication the other way around, where servers notify clients can be achieved by several means but is to be reserved for very particular needs. Are you sure you need that?

这篇关于身份cookie到期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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