你如何取消某人的永久性的Cookie,如果其成员不再有效? [英] How do you cancel someone's persistent cookie if their membership is no longer valid?

查看:134
本文介绍了你如何取消某人的永久性的Cookie,如果其成员不再有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计一个小ASP.NET MVC网站俱乐部。一般情况下,我希望用户能够保持登录状态,但如果用户的会员资格已失效,会发生什么?有没有什么办法,使下一次他们尝试查看页面去授权他们,这其重定向到一个页面,告诉他们自己的会员已过?

I'm designing a small ASP.NET MVC site for a club. Generally, I want users to be able to stay logged in, but what happens if a user's membership has lapsed? Is there any way to "de-authorize" them so that next time they try to view a page, it redirects them to a page telling them their membership has lapsed?

推荐答案

如果用于身份验证Cookie中定义的超时打将不再有效,用户将被自动重定向到登录页面。如果你想在某些情况下自动注销出来你可以简单地说:

If the timeout defined for the authentication cookie is hit it will no longer be valid and users will automatically be redirected to the login page. If you want to sign them out automatically under some circumstances you could simply:

FormsAuthentication.SignOut();

这篇关于你如何取消某人的永久性的Cookie,如果其成员不再有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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