I have my own website A written by thinkphp, and now I use react to develop website B. One of the two websites is localhost:8080 and the other is localhost:8081
The two websites have the same user system. After website A jumps to website B, website B needs to use the session of website A to maintain the login status. Currently, fetch is used
credentials = 'include'
Cooperating with the background
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: http://localhost:8081');
Cross-domain requests have been implemented
But the problem is that there is no cookie under port 8080 under port 8081, and the cookie cannot be carried to obtain the session status.
May I ask the experts how to solve it
Cookies can be set to take effect within the same domain.............
This problem should be solved on the server side. Put the session in a shared data area or database (such as redis). If different ports determine that the user is the same, the session data of the same user should be obtained and returned.