Codeigniter 2.1 $ this-> input-> set_cookie($ some_var);不工作 [英] Codeigniter 2.1 $this->input->set_cookie($some_var); NOT WORKING
问题描述
我开始创建一个自定义库,我将加载用于检查用户是否登录,以及注册用户。注册尚未开始,但这不重要...
I started creating a custom library that i would load for checking if user is logged in and also for registering users. Registration not started yet, but that's not important...
这里是有问题的部分。 it不会设置Cookie:
here's the problematic part.. it WON't set cookies:
$this->load->helper('cookie');
$some_value= 'asd';
$some_cookie_array = array(
'name' => 'some_name',
'value' => $some_value,
'expire' => 86500,
'secure' => TRUE
);
$this->input->set_cookie($some_cookie_array);
这里是现在的完整代码:
codepad.org/FILlq2qR
here is the full code for now: codepad.org/FILlq2qR
这是我如何调用库并检查用户是否登录:
This is how i call the library and check if user is logged in:
$this->load->library('user_management');
$login_data = $this->user_management->login();
var_dump($login_data);
任何帮助都是受欢迎的!
Any help is more than welcome!
干杯!
推荐答案
CodeIgniter论坛上的人帮忙。原因是我使用'secure'=> TRUE
,仅适用于https。
Someone on the CodeIgniter Forum helped. The reason was that I was using 'secure' => TRUE
which is only for https.
这篇关于Codeigniter 2.1 $ this-> input-> set_cookie($ some_var);不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!