Redirect after login to previous page

Hi, I have a question on the redirection, not sure if I am doing it correctly but here’s my code:

I put this code at

<!--Use this code to save the current page URL and redirect back after signup/login-->

  MemberStack.onReady.then(function(member) {
  if (!member.loggedIn) sessionStorage.setItem('redirect',window.location.href);

and I put the below code at Login page

<!--Place this on your page after signup/login - must be a hidden page-->

  var redirect = sessionStorage.getItem('redirect')
  if (redirect) window.location.replace(redirect)

Seems like every time I head over to login it will auto redirect me to Services page, and after login it won’t bring be back to Services page, may I know did I do it correctly any workaround on this? Thank you!

1 Like

Hey Steve, you’re suuuuper close.

  1. What page do you want to “Save” and send people to after signup?
  2. And what page do users land on (right now) after signing up and logging in? These are the pages you specified when setting up the membership.

You need to put the first snippet on #1 and the second snippet on #2.

Hi Duncan, thank you for the solution. But I tried that it works on login and registration but doesn’t seems to work on logout. But I found a pretty good video here which works for all.