CodeIgniter Forums
Header not set in CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Header not set in CI4 (/thread-79006.html)



Header not set in CI4 - waleed - 04-07-2021

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:iConfused') . '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:iConfused").'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.