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?
$this->input->set_cookie($cookie); In this method, only the first two parameters (name and value) are required. The expiration of the cookie is set through the expire parameter. This is the number of seconds the developer wishes to retain the cookie.
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);
This worked for me on localhost, security might need tightened for server
$this->load->helper('cookie');
$cookie = array(
'name' => 'data',
'value' => '23',
'expire' => 86500,
'secure' => false
);
$this->input->set_cookie($cookie);
var_dump($this->input->cookie('data', false));
Expire needs to be numeric, removed path and set secure to false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With