Home Backend Development PHP Tutorial 不同域名的cookie如何共享

不同域名的cookie如何共享

Jun 13, 2016 pm 01:14 PM
cookie http net quot

不同域名的cookie怎么共享
如题

------解决方案--------------------
不同域名的COOKIE不能共享。
但你说的若是一级域名相同的情况下,是可以的。设cookie path为 .顶级域名
------解决方案--------------------

探讨

引用:

不同域名的COOKIE不能共享。
但你说的若是一级域名相同的情况下,是可以的。设cookie path为 .顶级域名


我说的就是完全不同的,有些网站做到了,不知道怎么做的

------解决方案--------------------
说一说有些网站做到的场景是什么样的,也许未必是使用共享cookie呢?

探讨

引用:

不同域名的COOKIE不能共享。
但你说的若是一级域名相同的情况下,是可以的。设cookie path为 .顶级域名


我说的就是完全不同的,有些网站做到了,不知道怎么做的

------解决方案--------------------
假设有域名 www.a.net、www.b.net
各域名下均有 cookie.php 文件
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('<br>js cookie:'+document.cookie+'<br>');";
}else {
 print_r($_COOKIE);
 $url = $_SERVER['HTTP_HOST'] == 'www.a.net' ? 'www.b.net' : 'www.a.net';
 echo "<script src="http://%24url/cookie.php?token=%24_SERVER%5BHTTP_HOST%5D"></script>";
 echo "<a href="http://%24url/cookie.php">test</a>";
} <div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where are the cookies on your computer? Where are the cookies on your computer? Dec 22, 2023 pm 03:46 PM

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.

Where are cookies stored? Where are cookies stored? Dec 20, 2023 pm 03:07 PM

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

Where are the mobile cookies? Where are the mobile cookies? Dec 22, 2023 pm 03:40 PM

Cookies on the mobile phone are stored in the browser application of the mobile device: 1. On iOS devices, Cookies are stored in Settings -> Safari -> Advanced -> Website Data of the Safari browser; 2. On Android devices, Cookies Stored in Settings -> Site settings -> Cookies of Chrome browser, etc.

Detailed explanation of where browser cookies are stored Detailed explanation of where browser cookies are stored Jan 19, 2024 am 09:15 AM

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

How to implement HTTP streaming using C++? How to implement HTTP streaming using C++? May 31, 2024 am 11:06 AM

How to implement HTTP streaming in C++? Create an SSL stream socket using Boost.Asio and the asiohttps client library. Connect to the server and send an HTTP request. Receive HTTP response headers and print them. Receives the HTTP response body and prints it.

HTTP 200 OK: Understand the meaning and purpose of a successful response HTTP 200 OK: Understand the meaning and purpose of a successful response Dec 26, 2023 am 10:25 AM

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Fix 0x800713ec.NET Framework error code Fix 0x800713ec.NET Framework error code Mar 07, 2024 am 10:07 AM

If you encounter the .NET Framework error 0x800713ec when installing a program in Windows 11/10, there are some methods you can take to solve the problem. This error is usually caused by not having the correct .NET Framework version, but there can be other causes. Here, we explore some common root causes to help you identify your issue and resolve it as quickly as possible. The entire error message looks like this: One or more issues caused the installation to fail. Please resolve the issue and try the installation again. See the log file for details. 0x800713ec Fix 0x800713ec.NET Framework Error Code To fix 0x800713ec.NET Framework error code, follow the solutions below

See all articles