UTXplorer is a free and open source command line based tool which allows you to determine which users are logged into the machine and get a historical records of logins and logouts.
Detailed usage information is available in the included readme file.