2014-02-27 218 views
0

我有一个登录页面,当通过身份验证后返回到此页面的已通过身份验证的用户时,我希望他们自己重新进行身份验证。现在,这是我的:重置身份验证Cookie

protected void Page_Init(object sender, EventArgs e) 
{ 
    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 

    if (User.Identity.IsAuthenticated) 
    { 
     var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; 
     authenticationManager.SignOut(); 
    } 
} 

我该如何清除身份验证cookie并设置一个新的?我正在使用身份验证。

谢谢。

回答

1

要删除一个cookie,您将它的过期日期设置为过去的某个时间。如果您想要替换cookie,只需存储一个具有相同名称的新cookie。 More about cookies