Say the user is browsing the website and then performing some actions that change the database (let them add a comment). When asked to add a comment, we find that we need to get them to log in before they can continue.
Suppose the login page asks for the username and password and redirects the user back to the URL that they collected when the login is required. This redirect works to search for URLs with only GET parameters, but if the request originally contained some HTTP POST data that is now lost.
Can anyone recommend a way to handle this scenario when HTTP POST data is involved?
Obviously, if necessary, the login page could dynamically generate a form with all the POST parameters to pass them (although this seems messy), but even then I donโt know how to redirect the user login page to their intended page, saving POST data in the request.
Edit : one additional limitation that I had to make clear - imagine that we donโt know whether the login will be requested until the user sends a comment. For example, their cookie may have expired when they downloaded the form and actually submitted a comment.
source share