0

To solve the problem that pressing the browser back button to return, after closing session not will start again without asking for data entry, add the following code.

$this->output->set_header('Last-Modified:' . gmdate('D, d M Y H:i:s') . 'GMT');
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
$this->output->set_header('Cache-Control: post-check=0, pre-check=0', false);
$this->output->set_header('Pragma: no-cache');

But when I press the back button of the browser I get the message Confirm Form Resubmission. sorry my bad English

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user3324706
  • 11
  • 1
  • 3
  • where should I place : $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0"); $this->output->set_header("Pragma: no-cache"); – user3324706 Feb 25 '14 at 19:21
  • Within your Controller in which you submit the form. Note that headers must be sent at first. – Hashem Qolami Feb 25 '14 at 19:24
  • placed in the constructor of my class and when I pressed back button appears Confirm Form Resubmission :/ – user3324706 Feb 25 '14 at 19:32
  • The best option is [redirecting (302)](http://hashem.ir/CodeIgniter/helpers/url_helper.html#redirect) the *action* page to itself after submitting the form via POST. Take a look at here for further info: http://stackoverflow.com/questions/3923904/preventing-form-resubmission – Hashem Qolami Feb 25 '14 at 19:56
  • 1
    thank you very much friend, I could solve my problem with your help :D – user3324706 Feb 25 '14 at 20:28

1 Answers1

1
    $this->output->set_header('Last-Modified:' . gmdate('D, d M Y H:i:s') . 'GMT');
    $this->output->set_header('Cache-Control: no-cache, no-cache, must-revalidate');
    $this->output->set_header('Cache-Control: post-check=0, pre-check=0', false);
    $this->output->set_header('Pragma: no-cache');
Neil
  • 14,063
  • 3
  • 30
  • 51
murugeshak
  • 11
  • 2