前后端分离,解决session 刷新变ID
通过API接口实现前后端分离的项目,请求session ID 刷新就会改变,造成不断生成新的SESSION文件
1、$.ajax解决方案:
设置:
xhrFields: {
withCredentials: true
}
$.ajax({ url:api+'user/islogin', xhrFields: { withCredentials: true }, data:postdata, type:'json', method:'post', success:function(e){ } })
2、axios解决方案
axios.defaults.withCredentials = true;

浙公网安备 33010602011771号