We are writing a custom ending session code for our Site.come community. What we want to do is to query trough Apex the datetime of the last activity of the user logged in.

There is in Salesforce an object that stores information like UserId, datetime of activity (API calls, UI interactions ecc...)?

Our idea is to call the last activity datetime and if it's out of a certain limit (eg. now plus ten minutes) use logout.jsp to force the log out of the user.


You can do somthing like this

CustomSession__c customSession = [select Id, LastActivityDateTime__c from CustomSession__c where UserId__c =:currentLoggedInUserId order by LastActivityDateTime__c desc limit 1 ];

if(Datetime.now() > customSession.LastActivityDateTime__c.addMinutes(10)){
 //call logout page
| improve this answer | |
  • 1
    I did it, using jquery cookie library. Thank you for help – L.benedettini May 18 '17 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.