How to share cookies for different domain names

Source: Internet
Author: User
How to share cookies for different domain names is as follows: Cookies for different domain names cannot be shared. However, if you are talking about the same level-1 domain name, you can. Set cookiepath as A. top-level domain name. Reference: Cookies of different domain names cannot be shared. However, if you are talking about the same level-1 domain name, you can. How to share cookies with cookiepat with different domain names
Example

------ Solution --------------------
Cookies for different domain names cannot be shared.
However, if you are talking about the same level-1 domain name, you can. Set cookie path to. top-level domain name
------ Solution --------------------
Discussion

Reference:

Cookies for different domain names cannot be shared.
However, if you are talking about the same level-1 domain name, you can. Set cookie path to. top-level domain name


What I'm talking about is completely different. some websites have done it and I don't know how to do it.

------ Solution --------------------
Let's talk about the scenarios of some websites. maybe they may not use shared cookies?

Discussion

Reference:

Cookies for different domain names cannot be shared.
However, if you are talking about the same level-1 domain name, you can. Set cookie path to. top-level domain name


What I'm talking about is completely different. some websites have done it and I don't know how to do it.

------ Solution --------------------
Assume that there are domain names www.a.net and www. B .net.
Each domain name has a cookie. php file.
PHP code
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');if(isset($_GET['token'])) {  setcookie('name', $_GET['token'] . ' ' . $_SERVER['HTTP_HOST']);  echo "document.write('
js cookie:'+document.cookie+'
');";}else { print_r($_COOKIE); $url = $_SERVER['HTTP_HOST'] == 'www.a.net' ? 'www.b.net' : 'www.a.net'; echo "

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.