Use session to calculate the login times
Fix bugs