Clicking On Browser Back Button Shows "document Expired"

I’ve a chtml button in a “result” page. When it is clicked, it will bring you to the respective “result details” page.

However, when I’m at the “result details” page and I click the web browser’s back button to return to the “result” page, I’ll get a “Document Expired. This Document is no longer available.” error page from the web browser. When I refreshed the “Document Expired. This Document is no longer available” error page, I’ll get back to the “result” page.

Why is this so?

Anyway, I don’t have a form, I’m just using the button to link to the “result details” page.

Is there any way whereby I can click on the back button of the browser to return directly to the "result" page instead of showing the error and I have to manually refresh the page to get back to the "result" page?

Have you tried this in different browsers?

This usually happens if there is some POST data on your ‘results’ page. What you can do is use session variables to allow this:




//your results controller

public funtion actionResults()

{

    if(isset($_POST['fancy_data']) || isset(Yii::app()->session['fancy_data']))

    {

        $data = isset($_POST['fancy_data']) ? $_POST['fancy_data'] : Yii::app()->session['fancy_data'];

        Yii::app()->session['fancy_data'] = $data;

  

        //do your thang, gurl...

    }

}



This is what I do, and unless there is some security flaw I’m missing, it should work fine.

I’ve tried in all the browsers but it still happens.

In IE, the error is:

Webpage has expired

In Firefox, the error is:

Document Expired. This document is no longer available.

In Chrome, the error is:

Confirm Form Resubmission

I’ve changed my codes to your method. But the error still persist.

I can echo out the session value in all the pages. But when I clicked the browser “back” button at the “result details” to go back to the “result” page, the error page still comes out. But when I refreshed the error page, the page will appear with the echoed session value. So I think the session is there just that I don’t know why the “webpage has expired”.

Could it be because the "result" and "result details" are of different modules that cause the "webpage has expired" error?

Hi,

Please post your view so people here can help you better.

Ok. My codes are as follows.

View in “search” module with buttons to link to “projprofile” module’s index page through the controller:




<?php echo CHtml::button('View', array('submit' => array('default/viewProject','project_id'=>$data->project_id), 'class'=>'viewButton')); ?>



Controller that will bring you from “search” module to “projprofile” module’s index.php:




public function actionViewProject()

{

	$project_id = $_GET['project_id'];

	$this->redirect(array('/projprofile', 'proj_id'=>$project_id));

	

}



I’m not sure what I’m doing is right or not.

Probably I can explain in detail what I’m doing and maybe you all will have solutions or workarounds to the “document expired” problem.

I have a “search” module and in its view page, I have a button that I want to link to a “projprofile” module’s view page. However, the “projprofile” module’s view page would require parameters such as the project_id, in order to retrieve values from the model(database) according to the project_id, to display in the “projprofile” module view page.

Currently I have a button in the “search” module view page that calls the “search” module controller’s method. The “search” module controller’s method will then redirect to the “projprofile” module’s view page by passing the project_id.

The button can be linked to the “projprofile” view page. But when I clicked on the browser’s back button, it will give me “document expired” in firefox, “confirm form resubmission” in chrome or “webpage has expired” in IE.

Am I using the proper method of displaying another module’s view page? Is it because I’m using a wrong way that causes this problem?

Search module view page button:




<?php echo CHtml::button('View', array('submit' => array('default/viewProject','project_id'=>$data->project_id), 'class'=>'viewButton')); ?>



Search module controller’s method:




public function actionViewProject()

{

     $project_id = $_GET['project_id'];

     $this->redirect(array('/projprofile', 'proj_id'=>$project_id));

        

}