![]() |
how do I read request headers in codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how do I read request headers in codeigniter (/showthread.php?tid=38813) |
how do I read request headers in codeigniter - El Forum - 02-19-2011 [eluser]Unknown[/eluser] I tried using this Code: $this->input->get_request_header() Call to undefined method Code: CI_Input::get_request_header() Any idea why? I need to read a cookie value on the page and looks like I would have to do that with the headers being sent in. how do I read request headers in codeigniter - El Forum - 02-19-2011 [eluser]Basketcasesoftware[/eluser] There are already cookie functions in CI. There are the following methods available in the input class $this->input->cookie() // Returns the selected cookie value. $this->input->get_cookie() // Gets a specific cookie. $this->input->set_cookie() // Reverse of the previous. I don't know why are getting that error message. What version of CI are you using? Are you using it in a library or a controller method? how do I read request headers in codeigniter - El Forum - 02-19-2011 [eluser]Unknown[/eluser] I did try using the $this->input->get_cookie() and set_cookie() method ways you suggested above in my controller, but I got a similar error message. I am using 2.0 and am calling it from my controller. Am I doing it wrong? how do I read request headers in codeigniter - El Forum - 02-19-2011 [eluser]Basketcasesoftware[/eluser] How about sharing the section of code you are calling it from. No one can help you without some idea of the context where your problem is occurring. how do I read request headers in codeigniter - El Forum - 03-11-2011 [eluser]adgezaza[/eluser] I'm having a similar issue. I'm trying to make a call to the get_cookie() method from the input library but I am receiving this error. "Fatal error: Call to undefined method CI_Input::get_cookie() " I've loaded the helper for cookie and have used the call set_cookie() in the parent function. I'm not sure if this should be an issue. Here is the code that is creating the error. Code: class Main extends MY_Controller how do I read request headers in codeigniter - El Forum - 03-11-2011 [eluser]Edmundas KondraĊĦovas[/eluser] Since you've loaded the cookie helper, you can just fetch the cookie with a function. Code: $_platform = get_cookie('platform'); And if I recall correctly, getting the cookie via Input class is like this: Code: $_platform = $this->input->cookie('platform'); how do I read request headers in codeigniter - El Forum - 03-11-2011 [eluser]adgezaza[/eluser] You're right. And my 2nd day on CI is really shining through :/ how do I read request headers in codeigniter - El Forum - 03-11-2011 [eluser]bubbafoley[/eluser] [quote author="Edmundas KondraĊĦovas" date="1299907417"]Since you've loaded the cookie helper, you can just fetch the cookie with a function. Code: $_platform = get_cookie('platform'); And if I recall correctly, getting the cookie via Input class is like this: Code: $_platform = $this->input->cookie('platform'); This is correct. There isn't a function in the Input class called get_cookie(). The user guide implies there is one but upon inspection of the code the function doesn't exist. It makes sense, though, because get_cookie() in the cookie helper uses $this->input->cookie(). Code: function get_cookie($index = '', $xss_clean = FALSE) |