So, in one page I verify if the info given is right (it’s like a login), so if the person used the right credentials I save two infos in the session storage.
wixData.query("Login-Info").eq("nome", nome).find() //look through the db
.then((response) =>{
if(response.items.length>0){ //if I found anything
response.items.forEach( (item, index) =>{
if(item.senha == senha){ //I searched if the credentials were right, comparing the name and the password
acertou = true
session.setItem("logado", 'true') //here is the important part
session.setItem('id', item._id) //And here is the other important part
wixLocation.to('/login-info/' + item._id)
}
})
if(!acertou){
$w('#SI').show('fade') //Here I just put a msg if the password was wrong
}
}else{
$w('#NNE').show("fade") //here I just put a msg if the name wasn't found in the db
}
})
So here I saved two things on the session storage, if the person is loged (I used it as a boolean, like if this item exists then it means it’s true, if it doesn’t than it means it is false), and I used to store the id of the person loged.
I know the saving works because I created other Main Page and it output everything right.
But when I tried to recover these items from a dynamic page it just returns null, it creates an even bigger problem when it’s supposed to throw you back to the home page if the session storage is empty (what the page think it is), I did it to protect brute forcing into the pages.
I entered through the chrome inspect and saw that the session storage is alright.
the code is alright too because I doble checked it. Gonna post the code of a button that is supposed to output one of the session storage items
export function button3_click(event) {
console.log(session.getItem('id')
}
But it doesn’t output it right:
I tried passing the “job” of reading the session storage to the mainPage.js, exporting the function and importing it into the page, but the result is the same (and it is exactly the same, it worked on the test page, and in the home page, but it doesn’t on the dynamic page)
//code on mainPage.js
export function getid () {
return session.getItem('id')
}
export function getlogado () {
return session.getItem('logado')
}
An adicional thing a noticed is that the dynamic pages are giving a strange error when I open them, not related to my code, and maybe this is the reason this is not working, but I’m not sure
(when I force it to put me on those dynamic pages)
(and these errors when I go to the dynamic pages as I should)
I uploaded the log files if anyone is interested
(and I noticed that the errors have something to do with animationm, or 3d animations, but I didn’t use any, so that doesn’t make sense, and I don’t know how those errors would interfere with the sessions storage)
I just wanted to use the session storage, if anyone knows what happened or what I did wrong I would be very grateful. Thanks for any help, and if something I said didn’t make sense, I’m sorry english is not my first language, but you can ask me and I reword it