在codeigniter中,如何将数据存储在浏览器的cookie中?
我这样做
$this->session->set_userdata('above_eighteen',"1");
这是否是正确的方法,清除Cookie会不会这样做?
答案 0 :(得分:0)
与文档http://ellislab.com/codeigniter/user-guide/helpers/cookie_helper.html中一样,
设置Cookie:
$cookie = array(
'name' => 'The Cookie Name',
'value' => 'The Value',
'expire' => '86500',
'domain' => '.some-domain.com',
'path' => '/',
'prefix' => 'myprefix_',
'secure' => TRUE
);
$this->input->set_cookie($cookie);
获取Cookie:
cookie('The Cookie Name');
删除Cookie:
delete_cookie("The Cookie Name");