Path and domain parameter instance parsing for cookies

Source: Internet
Author: User
Tags set cookie setcookie
In a nutshell, the two parameters are:

Path indicates the directory where the cookie resides

Domain represents the field where the cookie resides, and the default is the requested address

First modify our Hosts file my native intranet IP 192.168.1.162


One.

We create a folder in the Web root directory cookietest Create a file index.php

 
  ';? >
Visit http://simael.php.com/cookietest/
Results:

No T3 T6 means that you cannot get a cookie for m0sh1.php.com under the domain name simael.php.com

Two.

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


There is no T4 T5 because the reason for setting the path when setting the cookie

Three.

Access http://simael.php.com/cookietest/index2.php Results:


Results same as (ii)

Four.

Access http://simael.php.com/cookietest/test1/index.php Results:


Results same as (ii)

Five.

Modify the/cookietest/index.php code

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



No T7 T8 to prove that the previous level directory cannot get cookies to the next level of directory settings
But there is a place that is not clear:
Above is the effect of Chorme browser
And look at Firefox.

The T7 error in the cookie is that I print $_cookie[' T7 ' result that I can't get T7 and look at the console.

There's no T7. Only under the Cookies tab can you see T7 but can't get it (this content just by the way--!)
Six.
Access http://simael.php.com/cookietest/test1/index.php Results:


That's when you see T7. Note that the cookie setting takes effect in the index.php of the previous level, except that it is only available under the corresponding path.
Seven.
Visit http://m0sh1.php.com/cookietest/index2.php

Only T2 T5 Note that setting a cookie for the domain name m0sh1.php.com in simeal.php.com is not effective, and because the cookie is set by the domain
Makes it possible to obtain a cookie under the Simeal domain name under this domain name
But can get to the. php.com Domain cookie information is set cookie for domain php.com
Cookie information can be obtained under any *.php.com domain

The above describes the path and domain parameters of the cookie parsing, including the aspects of the content, I hope that the PHP tutorial interested in a friend 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.