即使应用程序处于活动状态,我的会话也会自动过期

时间:2017-02-07 07:01:18

标签: c# asp.net

我在sessionState mode="InProc" timeout="30"文件中保留了web.config。 30分钟后,即使我的会话处于活动状态,它也会过期。如果会话在30分钟内处于非活动状态,我的要求是会话过期。如果它处于活动状态,则该过程需要继续。我正在使用asp.net。

Session.Clear();
Session.Abandon();
Session.RemoveAll();

if (Request.Cookies["ASP.NET_SessionId"] != null)
{
    HttpCookie currentUserCookie = HttpContext.Current.Request.Cookies["ASP.NET_SessionId"];
    HttpContext.Current.Response.Cookies.Remove("ASP.NET_SessionId");
    currentUserCookie.Expires = DateTime.Now.AddDays(-10);
    currentUserCookie.Value = null;
    HttpContext.Current.Response.SetCookie(currentUserCookie);
}

if (Request.Cookies["AuthToken"] != null)
{
    HttpCookie currentUserCookie = HttpContext.Current.Request.Cookies["AuthToken"];
    HttpContext.Current.Response.Cookies.Remove("AuthToken");
    currentUserCookie.Expires = DateTime.Now.AddDays(-10);
    currentUserCookie.Value = null;
    HttpContext.Current.Response.SetCookie(currentUserCookie);
}

0 个答案:

没有答案