PHP cross-domain cookie sharing usage _php tutorial

Source: Internet
Author: User
A the domain where the machine is located: A1.main.com,a has application main.php
B machine in the same domain: B1.test.com,b has application test.php

1. When setting a cookie in main.php, the cookie is set as follows:
Copy the Code code as follows:
Setcookie ("TestCookie", "Okol", Time () + 3600, "/", "b1.test.com", 1);

This allows the cookie to be taken in the test.php.

2. When you enter the URL to access test, you must enter the domain name to resolve.
For example, enter: http://b1.test.com/test.php, can get CAs in the client set cookie,
While the B machine accesses the application of this machine, input: http://localhost:8080/test.php can not obtain the cookie.

http://www.bkjia.com/PHPjc/825282.html www.bkjia.com true http://www.bkjia.com/PHPjc/825282.html techarticle a the domain where the machine is located: A1.main.com,a has the domain where the main.php B machine is applied: B1.test.com,b has application test.php 1. When setting cookies in main.php, how to set cookies ...

  • 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.