javascript - Fetch cross-domain request problem
高洛峰
高洛峰 2017-05-16 13:03:55
0
2
583

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

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
巴扎黑

Cookies can be set to take effect within the same domain.............

PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template