ajax发送时 写入以下参数
xhrFields: {
withCredentials: true
},
$.ajax({
url : '....' ,
type : 'get' ,
xhrFields: {
withCredentials: true
},
success : function(){
} ,
})
php端设置
header('Access-Control-Allow-Credentials: true');
如果是angulars
.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.withCredentials = true;
}]);