Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 38353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:41:41+00:00 2026-05-10T14:41:41+00:00

Say a user is browsing a website, and then performs some action which changes

  • 0

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:41:42+00:00Added an answer on May 10, 2026 at 2:41 pm

    2 choices:

    1. Write out the messy form from the login page, and JavaScript form.submit() it to the page.
    2. Have the login page itself POST to the requesting page (with the previous values), and have that page’s controller perform the login verification. Roll this into whatever logic you already have for detecting the not logged in user (frameworks vary on how they do this). In pseudo-MVC:
             CommentController {            void AddComment() {              if (!Request.User.IsAuthenticated && !AuthenticateUser()) {                 return;              }              // add comment to database            }             bool AuthenticateUser() {              if (Request.Form['username'] == '') {                 // show login page                 foreach (Key key in Request.Form) {                    // copy form values                    ViewData.Form.Add('hidden', key, Request.Form[key]);                 }                 ViewData.Form.Action = Request.Url;                  ShowLoginView();                 return false;               } else {                  // validate login                  return TryLogin(Request.Form['username'], Request.Form['password']);               }             }         } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to avoid the default chrome of the… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer Call: echo curl_error($ch); after the curl_exec to see what the… May 12, 2026 at 12:48 am
  • Editorial Team
    Editorial Team added an answer I've change the sample code to make it easier to… May 12, 2026 at 12:48 am

Related Questions

I'll try to explain my case as good as i can. I'm making a
I have a struts2 application with a single page that may show one of
Yes, another NULL vs empty string question. I agree with the idea that NULL
I'm looking to determine whether a string value from a user input (UITextField) is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.