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.