Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:31:33+00:00 2026-06-01T12:31:33+00:00

I have an automation system and I would like to record user logins and

  • 0

I have an automation system and I would like to record user logins and logouts. Therefore, I wrote a code which works nearly perfect. First of all, I record the user login with this code piece:

   if (UserLog.LoadByUserAndSessionAndLogoutTime(NHibernateHTTPModule.CurrentSession, user, Session.SessionID, null) == null)
    {
        UserLog userlog = new UserLog();
        userlog.LoginTime = DateTime.Now;
        userlog.LogoutTime = null;
        userlog.User = (Business.Classes.User)Session["User"];
        userlog.Session = Session.SessionID;
        userlog.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
        UserLog.Insert(NHibernateHTTPModule.CurrentSession, userlog);
    }

Then, in the Session_End event in Global.asax, I wrote this code piece;

            IList<UserLog> userlogs = UserLog.LoadBySessionAndLogoutTime(NHibernateHTTPModule.CurrentSession, Session.SessionID, null);
            foreach (UserLog userlog in userlogs)
            {
                userlog.LogoutTime = DateTime.Now;
                UserLog.Update(NHibernateHTTPModule.CurrentSession, userlog);
            }

Now, this trick works well but when I check the database at the end of the day, I have some zombie records which have login time but no logout time. It is obvious that for some users, either Session_End does not fire or something different happening which prevents updating. What I am missing? Why this is not working properly? Thanks in advance. NOTE: I am using NHibernate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:31:35+00:00Added an answer on June 1, 2026 at 12:31 pm

    Ok, allright, after couple days of analyzing, I finally have found the problem. It is the timeout amount of NHibernate. Timeout of both NHibernate and Application are set to fifteen (15) minutes. If a user do not close the application via the right way (using logout button I mean), that user will be logged on to the system for fifteen minutes after a succesful get – set call. After fifteen minutes passed, Session_End event has been fired to update the user log in database but as NHibernate timeout is also set to fifteen minutes, sometimes NHibernate session closed due to a time out before database update line in Session_End executed. Therefore, setting timeout of NHibernate to sixteen (16) minutes solved the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a role connected as SYSTEM. But because I have
I have the following automation code: lPrintSetup := fWordObject.Application.Dialogs.Item(wdDialogFilePrintSetup); lPrintSetup.Printer := 'MyPrinter'; lPrintSetup.DoNotSetAsSysDefault :=
I have classes which have automatic properties only like public customerName {get; set;}. They
We have InstallShield 2009 Premier installed on one system on which it is used
I have the following code that I have tested and works: using (new Impersonator(Administrator,
I have a XAML form that I would like two independent features threaded out
I have inherited a new (old?) Winforms project and would like to put it
I have an environmental build system which currently has the following environments: dev ci
I have created an Automation Add-in for Excel,implemented as a C# class library, which
We have an automatic reporting and notification system written in .net that sends emails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.