I am doing the frontend of a login system and am using pure javascript for this. I can already log in to the API and in the browser console to receive the data of the user that is logging on. This is my AJAX:
function loga() {
console.log("Enviando post");
let usuario = {
email: document.querySelector("#email").value,
senha: document.querySelector("#senha").value
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "http:web/rest/logins", true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.addEventListener("load", function() {
console.log(xhr.responseText);
if( xhr.status == 200) {
window.location="interno/index.php";
}
if(xhr.status == 500) {
var dadosInvalidos = document.querySelector('#dados-invalidos');
dadosInvalidos.classList.remove('invisivel');
}
});
xhr.send(JSON.stringify(usuario));
}
The ones that appear to me on the console are the id and the rest of the user data. What I need to know now is how do I move the user id to the home page, that is, the page that comes after the user logs in, so I can build the user profile on it. How can I do this? Can someone help me? Thanks in advance.