PHP cookie Odd Strange, inconsistent display
localhost/test.php
localhost/test/test.php
These two files are the same document that passed the examination
The content is a sentence print_r ($_cookie);
But the two URL shows are really not the sameof data Ah
Array ([TEST] = Test index)
Array ([Test] = test test)
Instinct is that I must have set it down,
But I have carefully examined n times, now is a word, print_r ($_cookie);
How does a cookie relate to a path?????
Set one time I will delete the next sentence, I set this, should not be related to the path AH
Setcookie ("Test", "Test Index", Time () +3600*24*1);
It is also stated that the data in the sibling directory is the same, and the solution ~~~~~~~~~~~~~~~~ Cookies PHP
Share to:
------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 the valid path, which is the default when the current directory is set. If set to/, the entire domain name is valid
Setcookie ("Test", "Test Index", Time () +3600*24*1, '/');