Session-session domain attributes

Source: Internet
Author: User

The domain attribute of the session identifies which domain name site the session belongs to. If we do not configure this in the PHP configuration file, it is the entire domain name value by default. For example, your domain name is aa. Bb.cc.com if you do any settings, you can see in the auxiliary tools that the seesion Domain value of this page is aa.bb.cc.com. Sometimes we need to use a multi-level domain name in a project, such as dd.bb.cc.com. In this case, we want the session to be available in both domain names, so we can set session_domain = bb.cc.com in the PHP configuration file.

 

With the above introduction, let's take a look at a problem some time ago: Due to server integration, we need to integrate several systems into a set of systems. The server architecture is like this: three front-end machines run nginx, two database machines, and two memcache caches. The three front-end servers use LVS for load balancing. Each server has the same configuration and runs multiple systems at the same time (for example, a.x.com; B .x.com; c.x.com) in the past, these three systems were distributed on different platforms, so session_domain is not configured. Now, these three systems are available on each machine, and each machine has the same configuration. Our requirement is that the three systems are independent from the outside. In this case, you do not need to set the session_domain value.

 

What will happen if we set such a value. For example, set it to .x.com.

All our session information is stored in memcache, And the session_name of the three systems is the same. Therefore, when you log on to system a, a session is generated. However, when you log on to system B at the same time, a new session changes the previous session of system. In this way, the data of the two systems becomes chaotic.

 

The above architecture is mainly based on the consideration of system reliability.

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.