Home > Article > Backend Development > Detailed explanation of how to use php cross-domain cookie sharing
This article mainly introduces how to use phpcross-domaincookie. Friends who need it can refer to
The domain where the A machine is located: a1.main.com, A has the application main.php
The domain where the B machine is located: b1.test.com, B has the application test.php
1. Set in main.php When using cookies, the cookie setting method is as follows:
The code is as follows:
setcookie( "TestCookie", "okol", time() + 3600, "/", "b1.test.com", 1 );
In this way, the cookie can be obtained in test.php.
2. When entering the url to access test, you must enter the domain name for resolution.
For example, enter: http://b1.test.com/test.php to get the cookie set by cas on the client.
And for machine B to access the local application, enter: http://localhost: 8080/test.php cannot obtain cookies.
The above is the detailed content of Detailed explanation of how to use php cross-domain cookie sharing. For more information, please follow other related articles on the PHP Chinese website!