header(“Access-Controller-Allow-Origin:*”);//用于解决同源策略,跨域访问
jQuery里ajax请求携带cookie:
$.ajax({
url:"{:url(‘index/Hello/api’)}",
type:“get”,
xhrFields: {
withCredentials: true // 携带跨域cookie
},
success:function(data,suc){
console.log(data.data);
}
})
header(“Access-Control-Allow-Credentials:true”);//用于接收跨域cookie
$_COOKIE[“name”];全局变量获取;
headers:{“token”:“liu”}axios里config配置请求头
header(‘Access-Control-Allow-Headers:token’);//跨域响应设置请求头