How to read state that application sent to /authorize endpoint

Hi All,

We are building a registration page where we need to remember last location of the application where user initiated from.

Here is the flow:

  1. User is on
  2. user click on login
  3. we initiated auth0 login with state=page/topic
  4. auth0 redirected to /login?stage=<some auth0 generated state>
  5. user sees a registration link on login page and click
  6. we redirected to a custom page with the capability of knowing that user initiated from page/topic
  7. user completed registration form and we send a verification link.
  8. this verification link has context of user’s original state i.e page/topic
  9. we verify the link somehow redirect user back to /authorize?state=page/topic so user can login and land on the initial location.

one approach I thought of saving state from login page but that will not work if user decided to login in different browser or after that state expires.

hence I am looking for a way to read original state value that application sent to /authorize endpoint or if any other option that I can use.

Thanks in advance for any advice.

Experts… any suggestion on this?