php shares usage methods across domains cookie

  • 2021-01-14 05:42:10
  • OfStack

a1.main.com, A, main.php, main.php, a1.main.com, A, main.php
b1.test.com, B, test.php, B, test.php

1. When setting cookie in main.php, you can set cookie as follows:


setcookie( "TestCookie",  "okol",  time() + 3600,  "/", "b1.test.com", 1 ); 

cookie is retrieved from test.php.

When accessing test, you must enter the domain name to resolve it.
Such as input: http: / / b1 test. com/test php, can obtain cas cookie Settings on the client,
And access to the application of the machine, machine B input: http: / / localhost: 8080 / test php is not cookie can be obtained.


Related articles: