How to keep confirmation messages after POST while doing a post-submit redirect?

Posted by MicE on Stack Overflow See other posts from Stack Overflow or by MicE
Published on 2010-03-20T23:03:40Z Indexed on 2010/03/20 23:11 UTC
Read the original article Hit count: 278

Hello,
I'm looking for advise on how to share certain bits of data (i.e. post-submit confirmation messages) between individual requests in a web application. Let me explain:

Current approach:

  1. user submits an add/edit form for a resource
  2. if there were no errors, user is shown a confirmation with links to:
    • submit a new resource (for "add" form)
    • view the submitted/edited resource
    • view all resources (one step above in hierarchy)
  3. user then has to click on one of the three links to proceed (i.e. to the page "above")

Progmatically, the form and its confirmation page are one set of classes. The page above that is another. They can technically share code, but at the moment they are both independent during processing of individual requests.

We would like to amend the above as follows:

  1. user submits an add/edit form for a resource
  2. if there were no errors, the user is redirected to the page with all resources (one step above in hierarchy) with one or more confirmation messages displayed at the top of the page (i.e. success message, to whom was the request assigned, etc)

This will:

  1. save users one click (they have to go through a lot of these add/edit forms)
  2. the post-submit redirect will address common problems with browser refresh / back-buttons

What approach would you recommend for sharing data needed for the confirmation messages between the two requests, please?

I'm not sure if it helps, it's a PHP application backed by a RESTful API, but I think that this is a language-agnostic question.

A few simple solutions that come to mind are to share the data via cookies or in the session, this however breaks statelessness and would pose a significant problem for users who work in several tabs (the data could clash together). Passing the data as GET parameters is not suitable as we are talking about several messages which are dynamic (e.g. changing actors, dates).

Thanks,
M.

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about web-development