Author: Rishabh Dubey
Salesforce provides the Last Login on the user detail page however there is no out-of-the-box feature for the Last logout in Salesforce.
1. LogoutEventStream and a trigger can be used to meet this requirement
- Enable Streaming for Logout Stream
- Go to setup
- Search for Event Manager
- Enable Streaming for Logout Event

2. Create a Last logout (Date/Time) field on the User Object
- Go to setup then object manager
- Open user Object
- Click on fields and relationship
- Click on New
- Select Date Time as the data type
- Give the label “Last logout”
- Select FLS and add it to the page layout

3. Create the below trigger on LogoutEventStraem Object
trigger Logoutinfo on LogoutEventStream (after insert) {
List <User> userList= new List <User>();
for( LogoutEventStream les:Trigger.new)
{
for(User userInfo: [Select ID,Last_Logout__c From User where ID =: les.UserID] )
{
userInfo.Last_Logout__c=System.now();
userList.add(userInfo);
}
}
update userList;
}
4. Test your Automation
- Log out from UI.
- Login again and open your user record.
- The last logout field should be updated by the time when you clicked Logout.

Note: This Automation will only show logouts done by UI, not from Session Time out.