How can I query the LoginHistory object from Apex?
you have to query LoginHistory object. I just tried to execute this from 'Developer Console' and works nicely
system.debug([SELECT ApiType,ApiVersion,Application,Browser,ClientVersion,Id,LoginTime,LoginType,LoginUrl,Platform,SourceIp,Status,UserId FROM LoginHistory limit 12]);
Go through Login History Object