Cookie path and domain parameter instance parsing

Source: Internet
Author: User
: This article describes how to parse cookie path and domain parameter instances. For more information about PHP tutorials, see. In one sentence, the meanings of the two parameters are:

Path indicates the directory where the cookie is located

Domain indicates the domain where the cookie is located. the default value is the request address.

First modify our hosts file my local intranet ip address 192.168.1.162


I.

Create a folder named cookietest in the web root directory to create the file index. php.

 ';?>
Http://simael.php.com/cookietest/ access
Result:

If no t3 t6 is available, the cookie setting for m0sh1.php.com cannot be obtained under the domain name simael.php.com.

II.

Access http://simael.php.com/results:


No t4 t5 is set because path is set during cookie setting.

III.

Access the http://simael.php.com/cookietest/index2.php results:


Results are the same as (2)

4.

Access the http://simael.php.com/cookietest/test1/index.php results:


Results are the same as (2)

5.

Modify/cookietest/index. php code

 ';?>
Access the http://simael.php.com/cookietest/index.php results:



Without t7 t8, the cookie set in the lower-level directory cannot be obtained from the upper-level Directory.
But there is something you cannot understand:
The above is the effect of the chorme browser
Now let's look at firefox.

The t7 error in cookies indicates that the result of printing $ _ COOKIE ['t7 '] cannot be obtained.

Obviously, there is no t7. you can only see t7 under the cookies tab but cannot get it (this content is just mentioned by the way --!)
6.
Access the http://simael.php.com/cookietest/test1/index.php results:


At this time, we can see that t7 indicates that the cookie setting takes effect in index. php at the upper level, but it can only be obtained under the corresponding path.
7.
Http://m0sh1.php.com/cookietest/index2.php access

Only t2 t5 indicates that the cookie setting for the domain name m0sh1.php.com in simeal.php.com does not take effect.
So that the cookie under the simeal domain name cannot be obtained under this domain name
However, the cookie information in the .php.com domain can be obtained, that is, the domain of the cookie is set to php.com.
You can obtain cookie information in any * .php.com domain.

The above describes how to parse the cookie path and domain parameter instances, including related content. I hope my friends who are interested in the PHP Tutorial will be helpful.

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.