Home >Backend Development >PHP Tutorial >How to replace php session with cache and cookies
The session concept no longer exists in the PHP 7 development framework I wrote myself
I want users to use caching + cookies to solve the problem
Actually, I want to know, simply maintain user login
Use cookies to symmetrically encrypt and store, then use PHP to decrypt and look up the table
There is actually no essential difference between recording the user uid in session and then looking up the table
Off topic
Cookies store the user’s hashed password and username. It is not impossible to simulate login every time
In fact, the database or cached data should be comparable to the practicality of session
After all, the session has a recovery mechanism. When 100,000 people log in to the website every day, the I/O bottleneck caused by the session mechanism may be more cruel than the bottleneck of the database
Another digression
Regarding the implementation of the shopping cart, it is actually possible to directly call the cache
key VALUE
User ID . Shopping cart content
I hope you guys can tell me what’s the point of still using session now, since it’s so random and unreliable
Reply content:
I want users to use caching + cookies to solve the problem
Actually, I want to know, simply maintain user login
Use cookies to symmetrically encrypt and store, then use PHP to decrypt and look up the table
There is actually no essential difference between recording the user uid in session and then looking up the table
Off topic
Cookies store the user’s hashed password and username. It is not impossible to simulate login every time
In fact, the database or cached data should be comparable to the practicality of session
After all, the session has a recovery mechanism. When 100,000 people log in to the website every day, the I/O bottleneck caused by the session mechanism may be more cruel than the bottleneck of the database
Another digression
Regarding the implementation of the shopping cart, it is actually possible to directly call the cache
key VALUEUser ID . Shopping cart content
I hope you guys can tell me what’s the point of still using session now, since it’s so random and unreliable
2. Since you need to use caching, it is better to go to Redis directly. Product information and the user’s shopping cart can be placed in the Hash table of Redis
No problem, that’s what restful means.
Oh, and don’t check the table every time you simulate login. It’s better to use redis or something to save the recently logged in user information