I’m trying to create a cookie with codeigniter for like 2 days -.- (I was to ashame to ask the question before…)
Anyone care to explain me what is wrong with this code:
$websiteUrl = preg_replace("/^[\w]{2,6}:\/\/([\w\d\.\-]+).*$/","$1", base_url());
$this->load->helper('cookie');
$cookie = array(
'name' => 'rememberMe',
'value' => $this->encrypt->encode(serialize($serialize)),
'expire' => (time() + $this->config->item('remember_me')),
'domain' => '.'.$websiteUrl,
'path' => '/',
'prefix' => 'chv_',
'secure' => false,
);
set_cookie($cookie);
(
$thisis CI instance)Make sure
$this->config->item('remember_me')> 0I was working with CI many times and i was always using native setcookie() function, because i really don’t need any framework to set cookie (it’s simple operation)… But according to documentation using CI instance and input
CI->input->set_cookie()should do the job. Remember NO FRAMEWORK is 100% perfect working… It’s only framework… You can debug step-by-step CI code to see what happens.(from comment)