function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Divya SoodDivya Sood 

Difference between UserLogin and loginHistory object.

Hi, 
What is the difference between userLogin and logiHistory object?
 
SwethaSwetha (Salesforce Developers) 
HI Divya,
Both the UserLogin and LoginHistory objects are related to user authentication and login activities, but they serve different purposes and provide distinct information:

The fields in Userlogin are
User-added image
The fields in loginHistory are
User-added image

​​​​​​​The UserLogin object focuses on an individual user's login activities and retains both successful and unsuccessful login attempts. On the other hand, the LoginHistory object provides historical data on successful user logins across the entire organization. Both objects are useful for monitoring user login patterns, identifying security issues, and analyzing user login activities over time.

Related documentation:
LoginHistory 
UserLogin

If this information helps, please mark the answer as best. Thank you
Divya SoodDivya Sood
What will be the query to find the number of external users logged into community.  which object should we use UserLogin or LoginHistory?