Inconsistent localhost/test. phplocalhost/test. php files are the same file. the previous content is one sentence. & nbsp; print_r ($ _ COOKIE). However, the php cookies displayed in the two URLs are inconsistent.
Localhost/test. php
Localhost/test. php
These two files were taken into consideration by the same document.
The content is a sentence print_r ($ _ COOKIE );
But the two URLs display different data.
// Array ([TEST] => TEST index)
// Array ([TEST] => TEST test)
I thought it was definitely me resetting,
But I checked it N times carefully. now it is a sentence: print_r ($ _ COOKIE );
How does the cookie have a relationship with the path ?????
Once set, I deleted the next sentence. I set it like this and it should not be related to the path.
// Setcookie ("TEST", "TEST index", time () + 3600*24*1 );
In addition, the data obtained from directories of the same level is the same ~~~~~~~~~~~~~~~~ Cookie PHP shared:
------ Solution --------------------
Setcookie (string $ name [, string $ value [, int $ expire = 0 [, string $ path [, string $ domain [, bool $ secure = false [, bool $ httponly = false])
The fourth parameter is to set a valid path. by default, it is the current directory when it is set. If it is set to/, the entire domain name is valid.
Setcookie ("TEST", "TEST index", time () + 3600*24*1 ,'/');
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