What would be the best way to redirect a user to a target page after they have logged in?

I am working on an application where the user can complete forms on pages anonymously, but also has the option to log in on each page. If they follow the log in link then they will be taken to the log in page, but I would like to track where they came from so that when they have completed the log in process I can send them back to the page that they were originally on. Is tracking this in a persistable entity the most efficient way to achieve what I'm trying to do (and how would I link it to my user's local account) or is there a better way?   Edit 19/12/2016: I have removed the "allow guests" permission from one of my deeplinks and forced it to sign an anonymous user in; what is this page called and which module does it live in? I have searched for "Sign in" and "Mendix 5" but the modeller returns no results.
2 answers

There is a blog post about this option: https://www.mendix.com/blog/using-the-after-sign-in-microflow/





You could associate an object to the user. When an anonymous use logs in, there's an option to run a microflow where you have both "user" objects (anonymous and registered) available to you and you can transfer any information you need between the two users. That microflow option is available in:

Project Security -> Anonymous users -> Sign-in microflow

This feature is most commonly used for transferring a user's "shopping cart" or similar objects, but I'm sure you could use it to track your user's location as well.


There may be another way to handle this even more efficiently through the use of the new Mendix page URL feature, but I haven't tried anything myself just yet.