WordPress achieves user logon under COOKIE second-level domain names

Source: Internet
Author: User
Tags subdomain subdomain name

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.