How do you get the same cookie value for different pages that are not associated with a website?

Source: Internet
Author: User
For example, a Web site has a few unrelated pages in the same directory: 1.php,2.php,3.php
A user generates a cookie after accessing 1.php:


Setcookie (' Mycookie1 ', $c 1);
Setcookie (' Mycookie2 ', $c 2);
Setcookie (' Mycookie3 ', $c 3);



If this user clicks the hyperlink from another website into 2.php, the result cannot read the cookie value of 1.php setting in 2.php.
If I do a hyperlink in the 1.php to 3.php, from the 1.php point hyperlink Access 3.php, on the 3.php will be able to display my 1.php set the cookie value:
The code for both 2.php and 3.php is the same:

$CC 1 = $_cookie[' mycookie1 ');
$CC 2 = $_cookie[' mycookie2 ');
$CC 3 = $_cookie[' mycookie3 ');
echo $CC 1;
echo $CC 2;
echo $CC 3;



How can I read the cookie value of 1.php settings in a 3.php page that is fully associated with 1.php?


Reply to discussion (solution)

Set the expiration period of a cookie variable

  • Related Article

    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.