[eluser]Unknown[/eluser]
Hello,
I'm pretty sure there is a bug here. Someone posted something years ago on this forum but nobody never answered so i prefer create a new topic for this issue.
Here is my configuration file :
Code:
$config['cookie_prefix'] = "bcc_";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;
Then, I register a cookie using :
Code:
$cookie = array(
'name' => 'mail',
'value' => $mail,
'expire' => '2592000',
'secure' => TRUE
);
$this->input->set_cookie($cookie);
At this point, everything is fine and I have a cookie named bcc_mail in my website cache.
But when i want to retrieve this cookie using :
Code:
$mail = $this->input->cookie('mail');
It always returns false. After looking at the core Input class, i saw that cookie method doesn't take into account config prefix for cookie.
Here is what I've done to achieve proper cookie working using prefix :
Code:
<?php
class MY_Input extends CI_Input
{
public function __construct()
{
parent::__construct();
}
function cookie($index = '', $xss_clean = FALSE)
{
$cookie = parent::cookie($index, $xss_clean);
return $cookie === FALSE ? parent::cookie(get_instance()->config->config['cookie_prefix'] . $index, $xss_clean) : $cookie;
}
}
I simply override the core method cookie to check whether or not the prefix is needed.
Regards,
Masadow