Home  >  Article  >  Database  >  The difference between redis and session

The difference between redis and session

藏色散人
藏色散人Original
2019-08-08 10:53:489495browse

Redis is an open source log-type, Key-Value database written in ANSI C language, supports the network, and can be memory-based and persistent. Session is called "session control" in computers, especially in network applications; the Session object stores the attributes and configuration information required for a specific user session.

The difference between redis and session

The difference between redis and session

Native session has higher reliability on the server side and can be stored in files, Database, memory.

Use Session to maintain the process of user login transition:

When the user logs in, the login form submitted is placed in the request;

The server verifies the user name and password;

After passing, the user information is stored in Redis, and the key in the database is session_id;

The set-cookie field in the response returned by the server contains the session_id, and the client will The value is stored in the browser;

The request for subsequent operations on the client will contain session_id. After receiving it, the server will extract it and get the session in Redis to complete the business operation;

When using Redis to realize session sharing and storage, you must ensure that the session_id cannot be easily obtained and cracked, and set a reasonable expiration time. Users must be verified again for sensitive operations.

For more Redis related knowledge, please visit the Redis usage tutorial column!

The above is the detailed content of The difference between redis and session. For more information, please follow other related articles on 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