CI class implements basic usage of session

高洛峰
Release: 2023-03-05 15:46:01
Original
1372 people have browsed it

First modify the configuration file (config.php)

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

Load SESSION class

$this->load->library('session');
Copy after login
Copy after login

Create SESSION

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

View SESSION

$this->session->userdata(session名);
Copy after login
Copy after login

Delete SESSION

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

First modify the configuration file (config.php)

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

Load the SESSION class

$this->load->library('session');
Copy after login
Copy after login

Create SESSION

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

View SESSION

$this->session->userdata(session名);
Copy after login
Copy after login

Delete SESSION

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!