-
- 127.0.0.1 www.a.com
- 127.0.0.1 www.b.com
Copy code
First: Create a_setcookie.php file:
-
- //header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
-
- setcookie("test ", $_GET['id'], time()+3600, "/", ".a.com");
- ?>
Copy the code
Then: Create a_getcookie.php file:
Finally: Create b_setcookie.php file:
Three After the files are created, access them sequentially through the browser:
-
- http://www.b.com/b_setcookie.php
- http://www.a.com/a_getcookie.php
Copy the code
while visiting the b.com domain, and There is no cookie value set in the a.com domain.
Then, modify the a_setcookie.php file and remove the comment symbols. a_setcookie.php is:
-
- header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
-
- setcookie("test", $_GET['id'], time()+3600, "/", ".a.com");
- ?>
Copy the code
Visit through the browser again:
-
- http://www.b.com/b_setcookie.php
- http://www.a.com/a_getcookie.php
Copy the code
to see if cross-domain has been implemented Visited.
|