ajax
ajax提交时无法保持session,如果利用的jquery ajax,则jquey供应了这个参数的设置:
$.ajax({ url: 'http://xxx.com', data: data, type: 'POST', xhrFields: { withCredentials: true }, crossDomain: true, success: function (data) { }, error: function (data) { }});
jquery ajax封装了xhr要求时的字段,须要设置“withCredentials: true”即可。

做事端相应头也要做如下变更:
'Access-Control-Allow-Origin' => $resuest->header('origin'),'Access-Control-Allow-Credentials' => 'true',
把稳,当“Access-Control-Allow-Credentials”为”true”时,“Access-Control-Allow-Origin”不能设置为“”,这里由于业务调试期间,客户端host不一定,直接设置当前要求头的“origin”即可。
附:
withCredentials的解释:
https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest/withCredentials