Call to undefined method CI_Input::get_cookie() - Code Igniter
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.
class Main extends MY_Controller
{
function __construct()
{
parent::__construct();
//load library
$this->load->helper('cookie');
echo "Welcome controller<br>";
}
function index()
{
//get platform cookie
$_platform = $this->input->get_cookie('platform'); //<-ERROR
开发者_Go百科 if (!$this->tank_auth->is_logged_in()) {
redirect('/auth/login/');
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$data['platform'] = $_platform['value'];
$this->load->view('welcome', $data);
}
}
}
Since you’ve loaded the cookie helper, you can just fetch the cookie with a function.
$_platform = get_cookie('platform');
And if I recall correctly, getting the cookie via Input class is like this:
$_platform = $this->input->cookie('platform');
http://codeigniter.com/forums/viewthread/181572/#867911
精彩评论