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