Home  >  Article  >  Backend Development  >  Why does the login reply on the Douyu website achieve long-term login?

Why does the login reply on the Douyu website achieve long-term login?

WBOY
WBOYOriginal
2016-08-22 11:45:391396browse

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?

Reply content:

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

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