Home >Backend Development >PHP Tutorial >Why does the login reply on the Douyu website achieve long-term login?
The login status on the Douyu website can be maintained for a week. If you simply use SESSION+COOKIE, what if you keep the login status? Is it using pure COOKIE?
The login status on the Douyu website can be maintained for a week. If you simply use SESSION+COOKIE, what if you keep the login status? Is it using pure COOKIE?
What is more popular now is to save the session id in the cookie and save the session status on the server (for example, using redis, the key is the session id)
For websites that are rarely visited, you can use session to add cookies, mainly by configuring PHP.ini to make the two expiration times (
session.cookie_lifetime, session.gc_maxlifetime) greater than 1 week.
Session storage, redis, etc. are also very convenient.
Save the session when logging in, such as saving your ID and username, and setting the validity period. The next time you perform an operation, if it is within the validity period and there is a matching ID and username in the session, you will log in directly to the system.
You can refer to localStorage and sessionStorage, this should be used