Home > php教程 > PHP开发 > body text

Issues to note when using encrypted session and session when logging in in the CI framework

黄舟
Release: 2016-12-29 09:50:48
Original
1873 people have browsed it

1, Note:

When logging in with a user password, store the password in the session. You need to set the secret key in the config.php file;

Then in the autoload.php file Set the session to load automatically;

2, use method

After the login password and username are verified correctly, save the password and username into the session for a more secure location

$sessionData = array(
'username' => $username,
'password' => $password,
'time' => time()
);
$this->session->set_userdata($sessionData);
Copy after login

3, take out session

$this->session->userdata("xxxxxxxxx"); (userdata中放取出的字段)
Copy after login

4, config.php sets the path of session storage


##

$config['sess_save_path'] =BASEPATH.'../'.'session_file';
Copy after login

session folder If it exists in the root directory, the session_file folder will be automatically created


If it is not set, an error will be reported:



A PHP Error was encountered 
Severity: Warning Message: mkdir(): Invalid path 
Filename: drivers/Session_files_driver.php Line Number: 117 
Backtrace: File: /Library/WebServer/Documents/CI/cinews/ci/index.php
Line: 316 Function: require_once
Copy after login
The above is the encryption used when logging in in the CI framework session and session issues to note. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template