3

Is there any way I can know when a Salesforce user logs out of the website?

I'm providing a service that will probably reside in an iFrame displayed on SF pages and need to know when to do some cleanup server-side (read: my server, not SF) when the user logs out of SF.

Whether through some Javascript call, or something from apex http callouts, or a controller, or any other mechanism.

Thanks

2

No, there isn't away to detect whether a user has logged out.

However, assuming your iframe is getting passed a session id, you might be able to do some sort ping routine that checks if the session is still valid, and when it is perform the clean up.

That said, it'd probably be a better use of your time figuring out how to make your process work without depending on knowing when the user logs out.

  • I agree - the only reason I'm trying to do this though is that from a user perspective, the service provided in the iframe shouldn't really persist beyond the SF session - the two things are well-integrated from a user perspective – Rhys Nov 27 '13 at 19:30
  • I know, kind of giving you a cop out answer :-/, just figured it helps to know when something could be a dead end. Best of luck with the project. – Ralph Callaway Nov 27 '13 at 23:07
3

It's 2019...

Now salesforce has provided ability to capture the logout event by releasing an object LogoutEventStream as a beta feature.

After LogoutEventStream is enabled, Salesforce publishes logout events when users log out from the UI. You can add an Apex trigger to subscribe to those events. You can then implement custom logic during logout.

For example, you can revoke all refresh tokens for a user at logout.

0

@Raven.

One client gave me a task to detect whether a user is logging out of salesforce. We have custom login mechanism and on log out we redirect user to custom logout page. During custom login mechanism I am going to set a cookie and on custom logout I read the value from the cookie and detect which user has logged out.

Ability to redirect user to custom logout page after logout is the new feature introduced in Summer 15 release https://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_security_auth_connapp_logouturl.htm

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.