Roman Roman - 3 months ago 18
PHP Question

How to retrieve cookie value in CodeIgniter?

I can print the session values in codeigniter by

print_r($this->session->userdata);

How can I print the cookies in codeigniter? I have just set a cookie:

$cookie = array(
'name' => 'test_cookie',
'value' => 'test',
'domain' => '/',
'secure' => TRUE
);

$this->input->set_cookie($cookie);


How can i print the above cookie?

Answer

Look at the documentation: Codeigniter Cookie Helper Guide

It says that you should use $this->input->cookie() to retrieve a cookie:

$this->input->cookie('test_cookie', TRUE);