Latest release of salesforce has an object name LoginHistory using which you can access the login history of any user.
For a particular user, you need to mention userID in SOQL query:
public void someFunction(){
LoginHistory logH= [select field1,field2,... from LoginHistory where userID='some_User's_id' limit 1];
// for one record.
// for multiple records you can store results in a list.
}
In case you want to get login details of current user then use following line instead.
LoginHistory logH=[select field1,field2,... from LoginHistory where userID=:userInfo.getUserID()];
No, login history is not currently exposed via the API.
it’s not possible but you can download from your org using salesforce user interface.
You should be able to access it now via Login History (LoginHistory)
Latest release of salesforce has an object name LoginHistory using which you can access the login history of any user.
For a particular user, you need to mention userID in SOQL query:
In case you want to get login details of current user then use following line instead.for detailed documentation, navigate to following page:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_loginhistory.htm