Welcome Guest, Not a member yet? Register   Sign In
codeigniter 4 "need define" in the model this data output->set_header
#3

(This post was last modified: 01-16-2021, 02:33 PM by yuma2020.)

(01-14-2021, 05:00 PM)iRedds Wrote: In my opinion. 
If you set headers in the model, then you are doing something wrong.
The controller should be responsible for setting the headers.

Up
PHP Code:
// In controller 
$this->response->setHeader('Pragma''no-cache'); 

//If you still want to do this in the model
Service::response()->setHeader('Pragma''no-cache'); 

https://codeigniter.com/user_guide/outgo...ng-headers


This would also be valid for calls from controllers or bookries, I simply consult because due to the great diversity there are many forms of calls, but the most appropriate ones would be great.

Example wants to set this from a helper, a library.

PHP Code:
//If you still want to do this in the model
Service::response()->setHeader('Pragma''no-cache'); 

I clarify this code is the one that works apparently in BaseController:
PHP Code:
$this->response = \Config\Services::response()->setHeader('Pragma''no-cache'); 
Reply


Messages In This Thread
RE: codeigniter 4 "need define" in the model this data output->set_header - by yuma2020 - 01-16-2021, 02:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB