[Code] Keep Members on the Same Page After Signup or Login

Article author
Memberstack Team
  • Updated

In this article, I'll show you a neat redirect hack. With a few bits of code, you can override the default Memberstack redirect and keep members on the same page after they log in or sign up.

Adding Site-Wide Code

This snippet saves the user's current page in the browser.

  1. Log in to your Webflow account and open a project.
  2. Open the Custom Code editor.
  3. Go to the Footer Code field and paste in this sitewide </body> code.

// sets the url of the page you're on for redirecting back to it
localStorage.setItem('locat', location.href);

Adding Page Code

Next, add the following code to a blank page. This snippet redirects the browser back to the saved page (see above).

  1. Open the Webflow Designer.
  2. Create a new page and give it a name (e.g. called Success).
  3. Scroll down the Settings page to the Custom Code field.
  4. Paste the following code into the Inside <head> tag field.
  5. Click Create and then Publish.

// redirects back to the page you were just on
window.location = localStorage.getItem('locat');


That's it.

Now you know how to keep users on the same page after they log in or sign up.

Was this article helpful?



Please sign in to leave a comment.