Form Re-submission Error |
Hye guys.
Just need a help!!! When I was using ci3 so I faced an issue when user clicked browser back button, that's show " resubmit the form", so I solved that issue after setting header in ci3. Now I upgrade my site ci3 to ci4 and again I m facing same issue. Can anyone plz convert this code in CI4? CI 3 code in Controller construct $this->output->set_header('Last-Modified:' . gmdate('D, d M Y H:i') . 'GMT'); $this->output->set_header('Cache-Control: no-cache, must-revalidate'); $this->output->set_header('Cache-Control: post-check=0, pre-check=0', false); $this->output->set_header('Pragma: no-cache'); CI 4 code in BaseController $response->setHeader('Last-Modified',gmdate("D, d M Y H:i").'GMT'); $response->setHeader('Cache-Control', 'no-store'); $response->setHeader('Cache-Control', 'no-cache'); $response->setHeader('Cache-Control', 'must-revalidate'); $response->setHeader('Cache-Control', 'post-check=0'); $response->setHeader('Cache-Control', 'pre-check=0'); $response->setHeader('Pragma','no-cache'); $response->setHeader('Cache-Control', 'no-cache'); In CI 4 it is not working. Any help will be appreciated.
You could try this and the end of your code/
PHP Code: // Sends the output to the browser What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I was facing same issue and didn't find any authentic solution using ci4.
main difference which i saw was in ci3 while setting header there is set-cookie index in header array but in ci4 cookie did not set by setting header. I hope someone also was facing that one.
This article may help you figure it out.
How to prevent form resubmission when page is refreshed (F5 / CTRL+R) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I found the solution by using the following code.
Paste the code in Base controller $response->removeHeader('Cache-Control'); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); Firstly remove the all build-in headers than add new ones. |
Welcome Guest, Not a member yet? Register Sign In |