javascript - Fetch跨域请求问题
高洛峰
高洛峰 2017-05-16 13:03:55
0
2
518

我有一个自己的网站A是thinkphp写的,现在使用react开发了网站B。两个网站一个是localhost:8080一个是localhost:8081

两个网站是同一套用户系统,在A网站跳转到B网站之后,B网站需要使用A网站的session来保持登录状态,目前使用fetch的

credentials = 'include'

配合后台的

header('Access-Control-Allow-Credentials: true');  
header('Access-Control-Allow-Origin: http://localhost:8081'); 

已经实现跨域请求

但问题是8081端口下没有8080端口下的cookie,无法携带cookie获取session状态,
求问大神们怎么解决

高洛峰
高洛峰

拥有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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!