Welcome Guest, Not a member yet? Register   Sign In
Webpage Expired / POSTDATA Expired
#1

[eluser]gscharlemann[/eluser]
I've setup a simple page that is populated with database information based on an item selected from a dropdown list. When you follow a link from the data to a detailed page everything works fine, but if I push the "back" button on my browser I get:

IE: Webpage Expired
Firefox: The page you are trying to view contains POSTDATA that has expired from the cache.

The item selected from the dropdown box is submitted via POST. How do I prevent this item from "expiring"?

The controller function is as follows:
Code:
function index() {
        $data['races'] = $this->race_model->get_races();
        $race_selected = $this->input->post('race');
        $data['race_selected'] = $race_selected;
        if(!empty($race_selected)) {
            $data['race_data'] = $this->race_model->get_race($race_selected);
        }
        $this->load->view('header');
        $this->load->view('raceresults', $data);
        $this->load->view('footer');
    }

Thanks for your help!
#2

[eluser]Damien K.[/eluser]
I think it has to do with the default headers set by your web server. Don't quote me on this, but you can try something like: header("Cache-control: private");

Cannot provide you with more info.
#3

[eluser]BrianDHall[/eluser]
This I'm afraid is just a side-effect of POSTing data - POST, according to HTTP specification, implies a possible server-side change to data, so rePOSTing something is considered dangerous and prompts the user if they really want to do that.

I'm not aware of how to avoid that, other than use GET.
#4

[eluser]kurucu[/eluser]
Either stop using post data, or use a redirect so that the results page is generated through GET or the session.

Although it's done for performance reasons, the implementation would be just like the search function on this forum. You POST to a search form, which forwards to to a search results page, generated by unique ID passed in the URI.
#5

[eluser]gscharlemann[/eluser]
Thanks for the feedback. Seems like the simplest solution is to change from post to get (which is what I did). I must be missing something because the form no longer works. I did two things:
1. changed the method in the form statement from post to get. This resulted in: www.url.com/?race=123
2. I changed the line:
Code:
$race_selected = $this->input->post('race');
to
Code:
$race_selected = $this->input->get('race');
in the function listed in my original post. For some reason the get() call is not returning the value of 'race'. This should be easy, I must be brain dead.
#6

[eluser]gscharlemann[/eluser]
One more thing:
Code:
print $_SERVER['QUERY_STRING'];
results in: race=123 (what I would expect).
#7

[eluser]Damien K.[/eluser]
I thought you have to turn on query string support in CI config...
#8

[eluser]gscharlemann[/eluser]
Bingo!
Code:
$config['enable_query_strings'] = TRUE;

Thanks for all your help!
#9

[eluser]kurucu[/eluser]
Wait. I didn't mean get. I meant via the URI, so using CI's routing to pass the variables into your functions. What's wrong with that (standard) behaviour?




Theme © iAndrew 2016 - Forum software by © MyBB