Home  >  Article  >  php教程  >  Issues to note when using encrypted session and session when logging in in the CI framework

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

黄舟
黄舟Original
2016-12-29 09:50:481865browse

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);

3, take out session

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

4, config.php sets the path of session storage


##

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

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

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)!



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