コード例 #1
0
    protected void lnk_logout_Click(object sender, EventArgs e)
    {
        #region Xoá cookies LoginSetting
        CookieExtension.ClearCookies(LoginSetting);
        #endregion

        #region Xóa cookie RolesUser
        CookieExtension.ClearCookies("RolesUser");
        #endregion

        #region Cập nhật lần đăng xuất cuối
        string values          = TatThanhJsc.TSql.UsersTSql.GetUsersByUserlastlockoutdate(DateTime.Now.ToString());
        string conditionUpdate = TatThanhJsc.TSql.UsersTSql.GetUsersByUsername(CookieExtension.GetCookies("UserName"));
        TatThanhJsc.Database.Users.UpdateUsers(values, conditionUpdate);
        #endregion

        #region Logs
        string logAuthor     = CookieExtension.GetCookies("LoginSetting");
        string logCreateDate = DateTime.Now.ToString();
        Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", logAuthor, logAuthor, "", logCreateDate + ": " + logAuthor + " đăng xuất khỏi hệ thống quản trị");
        #endregion

        Response.Redirect("login.aspx");
    }