Retaining HTTP POST data when a request is interrupted by a login page

Question :

Retaining HTTP POST data when a request is interrupted by a login page,

Answer :

Say a user is browsing a website, and then performs some action which changes the database (let’s say they add a comment). When the request to actually add the comment comes in, however, we find we need to force them to login before they can continue.

Assume the login page asks for a username and password, and redirects the user back to the URL they were going to when the login was required. That redirect works find for a URL with only GET parameters, but if the request originally contained some HTTP POST data, that is now lost.

Read More  Default Internet connection on Dual LAN Workstation

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 along (though that seems messy), but even then, I don’t know of any way for the login page to redirect the user on to their intended page while keeping the POST data in the request.

Edit : One extra constraint I should have made clear – Imagine we don’t know if a login will be required until the user submits their comment. For example, their cookie might have expired between when they loaded the form and actually submitted the comment.

Read More  Why doesn’t inheritance work the way I think it should work?


This is one good place where Ajax techniques might be helpful. When the user clicks the submit button, show the login dialog on client side and validate with the server before you actually submit the page.

Another way I can think of is showing or hiding the login controls in a DIV tag dynamically in the main page itself.

That’s the answer Retaining HTTP POST data when a request is interrupted by a login page, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  How to animate the command line?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you