我有User
表。我使用Forms
認證,並具有以下代碼的登錄:如果我從DB中刪除用戶,則用戶保持認證(大會話超時)
public JsonResult LogOn(FormCollection form)
{
var agent = SiteUserRepository.CheckAgent(form["Email"], form["Password"]);
if (agent == null)
return Json(new
{
IsSuccess = false,
Message = "Wrong email or password"
});
SiteUserRepository.UpdateLastLogon(agent.Email);
FormsAuthentication.SetAuthCookie(agent.Email, true);
ApplicationSession.CurrentUser = agent;
return Json(new
{
IsSuccess = true
});
}
的ApplicationSession
是我Session
對象包裝。
public static class ApplicationSession
{
private const string _currentUser = "CurrentUser";
public static SiteUser CurrentUser
{
get
{
var user = HttpContext.Current.Session[_currentUser];
if (user != null)
return (SiteUser)user;
return null;
}
set
{
HttpContext.Current.Session[_currentUser] = value;
}
}
}
會話超時等於1440(24小時)。我需要這個價值。 例如,用戶在網站上登錄。然後我從數據庫中刪除這個用戶。用戶將被認證(如果他們當然沒有點擊註銷)。解決這個問題的最佳方法是什麼?
我不認爲它會起作用。因爲我將用戶從其他應用程序(CMS)中刪除。 – user1260827