首页 > 代码库 > CodeIgniter 错误: In order to use the Session class you are required to set an encryption key

CodeIgniter 错误: In order to use the Session class you are required to set an encryption key

第一次使用session,需要:

$this->load->library(‘session‘);

的同时,还需要修改配置文件:config.php 找到 $config[‘encryption_key‘] = ‘’

将$config[‘encryption_key‘] 的内容随便设置,就可以用了。

附录:

1.添加session内容:

$this->session->set_userdata(‘user_name‘, $userinfo[‘user_name‘]);

2.获取session内容:

$name= $this->session->userdata(‘user_name‘);