2

I have a basic question about Salesforce session: How can I logout my users automatically when they close the browser window?

2
  • I don't know of a way to do it with native pages. The only work around I can think of would be to make the timeout value really short (15 minutes). This of course adds a usability problem for your users if they leave a session inactive. Commented Dec 12, 2012 at 15:26
  • What if the user opens multiple tabs/windows? Do you log them out if they close just one of the tabs/windows? Is there any reliable way to know when they've closed all tabs/windows? Why do you want to log them out automatically?
    – tomlogic
    Commented Dec 13, 2012 at 6:25

3 Answers 3

1

Well, to log a user out you redirect them to /secur/logout.jsp ... however enforcing that mechanism would either have to be done via JavaScript or in theory you could also use a Browser Extension

0

I think if we talk about custom pages then by using JS this may be possible (that also need POC), but other than that it is quite impossible to do this with all native pages (home page component can help?).

0

I see this is an old thread but I thought I would share a workaround I discovered ...

Add a controller to your site home page, and in the init action, redirect to secure page, if it is not already a secure page.

public PageReference init() {
        String currentURL = Site.getCurrentSiteUrl();
        if (!startsWith(currentUrl, 'https://')) {
            return redirect(currentURL.replace('http://', 'https://'));
        }

        return null;
    }

Link to the thread HERE

1
  • This doesn't seem to logout users at all, but rather force them to use the HTTPS version of salesforce, and then only works on Sites - it wouldn't work for internal salesforce users. Commented Oct 2, 2013 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .