Home  >  Article  >  Backend Development  >  Detailed explanation of how to use php cross-domain cookie sharing

Detailed explanation of how to use php cross-domain cookie sharing

怪我咯
怪我咯Original
2017-07-10 10:01:272841browse

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!

Statement:
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