How to stop a user from pressing the back button to log back in?

Hi! So I was wondering if there is a way to disable the feature where you can press the back button?

Hi @testaccountj2, in this case I will use the plugin Detect user leaving page from @Anticode . :slight_smile:

2 Likes

Hey @JohnMark really appreciate all the mentions and referrals but we don’t have such a plugin :slight_smile:
Or was it a hint that we should create one :joy:

1 Like

You can use Browser Exit Event plugin to detect someone leaving the page by various methods.

I’m just curious, under what circumstance would clicking ‘back’ log the user in?

I’ve got it set up where "When Current User- Presses ‘Log Out’ it log the user out, and goes to page ‘Login_Sign in’’ But that makes it able where the use can press it to got back to the Page they were last in.

Are they then able to do POST requests, modify data etc.? I would assume not given that they should be logged out (technically). Going back to the previous page (which is likely loaded from the browser’s cache) doesn’t mean it should recreate their session. However, I may be wrong in Bubble’s context (still a new user here).

No their not able to modify anything

Depending on what you are trying to do, I’d recommend reading up on creating a single page application or SPA. This may not be the right option for you, but in general there is a bit that goes into how you organize your app that can inherently solve this issue (and many others) for you.

To answer your question directly:
You may want to check out the ‘browser’ plugin by copilot and utilize the ‘replace url’ workflow action. This re-writes the current history entry url in the user’s browser. You could attach this to the when button ‘log out’ is clicked workflow and set it the logout page. This would only work for the current history entry (so only on the page immediately proceeding a logout).

In theory, if your user is logged out, they shouldn’t be able to see private data on your pages that is only available to logged in users (see data tab > privacy tab in the editor) although they may see a ‘broken’ version of the page. You can also build page loading workflow on your ‘logged in’ pages i.e. when a page is loaded and user isn’t logged in then go to page login thereby redirecting your users to the login page if they attempt to access the private pages.

2 Likes

Put a conditional statement on the content and redirect users when logged out.

This topic was automatically closed after 70 days. New replies are no longer allowed.