不确定为什么Cookie无法在CI 2.x中运行。这是我的代码:
控制器: dashboard.php
class Dashboard extends CI_Controller {
public function index()
{
$this->load->helper(array('form', 'cookie', 'login'));
do_login("superuser"); // called the helper function from login helper
$data['c'] = $this->input->cookie('superuser');
$this->load->view('dashboard/show', $data);
}
帮助者: login_helper.php
function do_login($cname)
{
$cookie = array
(
'name' => $cname,
'value' => 'The Value',
'expire' => '86500',
'domain' => '',
'path' => '/',
'prefix' => 'myprefix_',
'secure' => TRUE
);
get_instance()->input->set_cookie($cookie);
}
查看: show.php
<pre>
<?php
print_r($c);
?>
</pre>
但是在我加载此页面时我什么也看不见!即使没有创建cookie,如EditThisCookie chrome插件所示。我错过了什么吗?感谢