This is also the case in WordPress. We can find some functions related to cookies in the WordPress kernel, and their parameters all require a domain. However, the default settings of WordPress may be different for different servers.
According to some information, the default settings of WordPress are as follows:
The code is as follows: |
Copy code |
Define ('cookie _ DOMAIN ',' .example.com '); |
That is to say, the cookie in WordPress is valid in example.com and all its subdomains. For example, if you log on to your primary site, the logon information in the subdomain is also valid.
However, such settings without domain name restrictions will bring about some security issues. For example, if you open the subdomain name to all users, some users set the same cookie as the other sub-domain name under a sub-domain name (although this case is relatively small), it may cause confusion of login information, you can even log on to another user's account.
Therefore, many people suggest adding one sentence in the wp-config.php:
The code is as follows: |
Copy code |
Define ('cookie _ DOMAIN ', 'www .example.com '); |
So that the cookie can only take effect under this domain name.
However, sometimes we also need cookies to take effect in some subdomains to implement some special requirements. In this case, you generally have full control over your own subdomain names, and these subdomain names use the same database, so that the above-mentioned serial line problems do not occur.