PHP cookie Odd paradox, inconsistent display

Source: Internet
Author: User
Tags setcookie
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, '/');
  • 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.