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 3428598
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:58:42+00:00 2026-05-18T06:58:42+00:00

I am using the POST/REDIRECT/GET pattern in my application. However, I have a problem:

  • 0

I am using the POST/REDIRECT/GET pattern in my application. However, I have a problem:

In case I want to display a message at the GET stage, I can store it as as session variable at the POST stage (when it is decided what message should be displayed), for example $_SESSION['message']='mplampla';

Using this technique, the message should be unset after being displayed in order not to display it again erroneously in other pages. But if user the goes back and then forward to the GET page again, the message won’t display the second time as it has been unset the first time around.

I don’t know how other websites manage this… I have seen a web site with a registration form, which displays a message after successful registration under the same URL and works correctly when doing back/forward.

  • 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. Editorial Team
    Editorial Team
    2026-05-18T06:58:42+00:00Added an answer on May 18, 2026 at 6:58 am

    Don’t store the message in $_SESSION. Instead, pass it as a parameter to your GET page.

    For example, in the GET stage, redirect the user to

    http://localhost/widget.php?edit=1&message=saved

    Then, in widget.php do:

    $message = isset($_GET['message']) ? $_GET['message'] : null;
    $output = null;
    switch($message) {
        case 'completed': // possibly use a constant here, eg MESSAGE_COMPLETED
            $output = 'Your changes has been saved.';
            break;
        case 'failed':
            $output = 'ERROR: failed to save changes!';
            break;
    }
    
    // Now present $output to the user anyway you like
    

    If the user goes back and forward, the message will still be displayed just fine. It also avoids any problems having to do with session state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Redirect After Post pattern in my ASP.NET MVC application. I
I'm using the Post/Redirect/Get pattern on a form of mine. I've never used this
I am using the post-redirect-get pattern for all my forms, but now need to
What's the difference when using GET or POST method? Which one is more secure?
I am using a perl script to POST to Google Appengine application. I post
I'm using httpc:request to post some data to a remote service. I have the
I always use the Post/Redirect/Get method on my forms. My forms generally always submit
Background I'm using POST form submissions instead of links with concatenated arguments inside a
I'm using $.post() to call a servlet using Ajax and then using the resulting
I'm using jQuery to post a form to a php file, simple script to

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.