A website the same domain name different directory of the file access to the cookie value is different what reason?

Source: Internet
Author: User
Tags setcookie

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?

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.