Add key to header in all page |
Hello
I have many controller that i need add key to header when i call other page or controller Example When i redirect to controller/method,i add key to header before redirect Maybe?
(12-14-2017, 11:26 AM)Wouter60 Wrote: Please, explain what you mean by a key that you want to add to a header. I make api that it is working with header I add user id in header key and check data according to it Now i make site for use this api And i cannot this api and i have to send header for api if i need use it
Try this:
PHP Code: $this->output->set_header('Authorization : APIKEY your-api-key-here'); before you load the view for the page that has to be displayed.
You can't use a header with the name 'mobile'.
For a complete list of headers, see: https://developer.mozilla.org/nl/docs/Web/HTTP/Headers But why do you need a header to pass a value to a model? You can include the code in the url, like this: http://website/test/test_value/0910000000 Your controller (test) gets the value as a parameter for the function test_value: PHP Code: public function test_value($mobile) Or, you can assign a value to a session variable for later use: PHP Code: $this->session->mobile = '0910000000'; After a redirect to another page, your controller can read the value like this: PHP Code: $mobile = $this->session->mobile; And then, you can pass this value to your model to check the corresponding data.
(12-15-2017, 09:03 AM)Wouter60 Wrote: You can't use a header with the name 'mobile'. I cannot pase field in url because i use header key in all model that i send it from app to api Finally i decide to use session that you suggest me Thanks |
Welcome Guest, Not a member yet? Register Sign In |