Home >Backend Development >PHP Tutorial >CI class implements basic usage of session

CI class implements basic usage of session

高洛峰
高洛峰Original
2017-02-09 09:46:051433browse

First modify the configuration file (config.php)

//生成一个随机不重复的字符串走位加密的key保存到config.php的encryption_key中
$config['encryption_key']='bf363d0a';

Load SESSION class

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

Create SESSION

$array = array('id'=>1,'name'=>'niu');
$this->session->set_userdata($array);

View SESSION

$this->session->userdata(session名);

Delete SESSION

$this->session->unset_userdata('SESSION名');

First modify the configuration file (config.php)

//生成一个随机不重复的字符串走位加密的key保存到config.php的encryption_key中
$config['encryption_key']='bf363d0a';

Load the SESSION class

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

Create SESSION

$array = array('id'=>1,'name'=>'niu');
$this->session->set_userdata($array);

View SESSION

$this->session->userdata(session名);

Delete SESSION

$this->session->unset_userdata('SESSION名');

For more articles related to the basic usage of CI classes to implement sessions, please pay attention to the PHP Chinese website!             

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn