简体   繁体   中英

SignIn and SignOut checks

am a beginner to java and have a doubt while recording the signIn and signOut timestamps in mysql database. Here I need to check few conditions. 1) The user is logged in with his username and password. At that point, his login time is not recorded. 2) The user signIn time will be sent to the database when he clicks the signIn button present in his account.

Now the problem I have is , 1) I can enter the signIn time many times, though the signOut time is not recorded. 2)when signed out that particular signed out time is recorded at the first timestamp I signedIn.

Can anyone suggest me the check I need to make so that every login should have logout.

Thanks in advance.

I believe that you should do the following check:

During the "sign-in" ( SI1 ) check whether there is a previous "sign-in"( SI0 ) event for this user with no corresponding "sign-out"(SO0).

If you detect such SI0 with no corresponding SO0 - assign this "sign-in" event a "sign-out" time of SI1 , otherwise - business as usual.

This way you always close previous sign-ups for user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM