我正在使用 PHP 编写 Api。Api 由 React Web 客户端调用。我正在使用 Axio 调用 Api。当我向我的 Api 发送一些东西时,SessionID 不是持久的,它在每次调用后都会改变。有人有什么想法吗?
简化的 PHP-Api:
<?php
session_start();
echo session_id();
/*
//Doesnt mather
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');
header('Content-type: application/json; charset=utf-8');
*/
?>
简化的 React-Client
static vote(vote, callback)
{
const data = {
action: 'vote',
vote: vote,
}
axios.post(api_url, qs.stringify(data))
.then(callback)
.catch((error) => {
console.log(error);
});
}