I have stored the data returned by a form of my application on the browser from sessionStorage. However I cannot access the stored values from another code file in my project and it gives me no error. I was expecting to be able to access these values anywhere just by specifying the names of the variables where they were saved. Here is the code from my useSendVerificationEmail.jsx
file where I declared and assigned values to variables stored on my browser:
import { createStore } from "solid-js/store";
import { createSignal } from "solid-js";
const [form, setForm] = createStore({
firstName: "",
lastName: "",
email: "",
password: "",
gender: "",
});
sessionStorage.setItem("firstName", form.firstName);
sessionStorage.setItem("lastName", form.lastName);
sessionStorage.setItem("email", form.email);
sessionStorage.setItem("password", form.password);
sessionStorage.setItem("gender", form.gender);
and here's the code from my useResendEmail.jsx
file where I'm trying to access these saved values and I can't:
import { createSignal } from "solid-js";
export default function useResendEmail() {
// ... code ...
const firstName = sessionStorage.getItem("firstName");
const lastName = sessionStorage.getItem("lastName");
const email = sessionStorage.getItem("email");
const password = sessionStorage.getItem("password");
const gender = sessionStorage.getItem("gender");
// ... more code ...
}
I want to clarify that these constants were not declared in the file useSendVerificationEmail.jsx
.
I was expecting this to work and I don't understand why it is doing this. Could someone please explain my mistake to me, thanks!