为什么我的 cookie 没有加密?我将它们视为纯文本,我可以轻松编辑它们,因为它是纯文本:O
我在用着:
$config['sess_cookie_name'] = 'sess_id';
$config['sess_expiration'] = 0; //24hours -> 8640
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'session';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 3000000000;
$config['encryption_key'] = 'dfs78fh834fh83h4fhhsdifsihdfh99inf83kjwnefkjwenfknwkejnfowejnf82';
并设置 cookie 我使用如下所示的钩子:
function setUserCountry($country){
$CI =& get_instance();
$CI->input->set_cookie(
array(
'name'=>'user_country',
'value'=>str_replace(array('"',"'",">","<"),"",$country),
'expire'=>'8650000000',
'secure'=>TRUE
));
}
这个钩子叫做 pre_controller:
$hook['pre_controller'] = //run my cookie hook setUserCountry() method
这就是创建 cookie 后的样子: