A website (e:\test):
It contains multiple directories such as:
htmlcssjsphpimg.....
Wait a minute.
Then, I set a cookie in the JS file in the JS directory, and also set a cookie in the php file in the PHP directory. Then open the JS file in the JavaScript directory to read the cookie and PHP files in the directory (JS script) read the cookie. Can not be fully read to this site cookie! You can only read cookies that are set in the same directory as JS or PHP files.
The full cookie value can only be read in the root directory of the Web site. Is there a way to make a cookie under the same website regardless of the file in which directory is set, as long as the file under the site, can read the full value of the cookie??
has been resolved:
ls|
Document.cookie= ' username=test;password=123456;expires= ' +new date (new Date (). GetTime () +3600*1000). toUTCString () + ';p ath=/;d omain=www.example.com ';
Php:
Setcookie (' username ', ' test ', 0, '/', ' www.example.com ');
Setcookie (' Password ', ' 123456 ', 0, '/', ' www.example.com ');
Source:
https://segmentfault.com/q/1010000004388893
A website the same domain name different directory of the file access to the cookie value is different what reason?