- Local time
- Today, 04:53
- Joined
- Feb 28, 2001
- Messages
- 29,996
When I had this same goal and this same kind of problem, I quickly realized that I needed a couple of facts. One of them was whether it was EVER reasonable to log in to the DB twice from two different terminals as the same user AND from a separate window to allow two simultaneous sessions from the same terminal. I got permission from the security guy to say "NO" to both questions. My login table included username and computername from the session login and also had session start date/time and end date/time - plus the "Abnormal" flag. (If that seems a bit strict, remember I was working for the U.S. Navy at the time. Their idea of security includes some things I wouldn't have guessed.)
That table enabled me to open a recordset to the session table to find the session record with the highest start date/time (before I wrote the current record) for the username logging in again. Relatively easy. If the record had an end date/time, I was done. If not, I updated that record to (a) put the current date/time as "END" for that session and (b) set a flag in the record that said "Abnormally terminated." Once that record was done, I could then enter a new session. I made it a point to, after the fact, capture the session number (which was an autonumber for that session table.) That way, if the user was exiting normally, in the dispatcher form's Close routine I could write a simple
"UPDATE SESSIONS SET ENDSESS= Now() WHERE SESSID = " & Me.SessionID & ";"
That way I could count sessions, abnormal sessions, and the duration of normal sessions easily. There was just about NEVER a chance to capture the correct session end for an aborted session, so the question was what to do about it. Therefore, by having a way to at least know the difference between orderly and disorderly session terminations, I had very few dangling sessions. I ALSO had a supervisor's maintenance tool that I ran during scheduled maintenance when the DB was still "officially down" and thus could not be logged in. It looked for sessions with no end date/time and immediately capped those off, too.
I don't know if that will help, but it was how I approached the problem.
That table enabled me to open a recordset to the session table to find the session record with the highest start date/time (before I wrote the current record) for the username logging in again. Relatively easy. If the record had an end date/time, I was done. If not, I updated that record to (a) put the current date/time as "END" for that session and (b) set a flag in the record that said "Abnormally terminated." Once that record was done, I could then enter a new session. I made it a point to, after the fact, capture the session number (which was an autonumber for that session table.) That way, if the user was exiting normally, in the dispatcher form's Close routine I could write a simple
"UPDATE SESSIONS SET ENDSESS= Now() WHERE SESSID = " & Me.SessionID & ";"
That way I could count sessions, abnormal sessions, and the duration of normal sessions easily. There was just about NEVER a chance to capture the correct session end for an aborted session, so the question was what to do about it. Therefore, by having a way to at least know the difference between orderly and disorderly session terminations, I had very few dangling sessions. I ALSO had a supervisor's maintenance tool that I ran during scheduled maintenance when the DB was still "officially down" and thus could not be logged in. It looked for sessions with no end date/time and immediately capped those off, too.
I don't know if that will help, but it was how I approached the problem.