I created a registration form in my solid-js application. I would like that after the submission of the form, that the values entered disappear from the input fields of the form but are kept on the browser of the user temporarily (until the shutdown of the computer) in order to be able to get these values later in other code files. For this, I therefore decided to use sessionstorage and wrote the following code in my useSendVerificationEmail.jsx
file:
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 in order to use these values in other files, I do this in another file of my projet more precisely in my useResendEmail.jsx
file so the previous code and the following code come from two different files:
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')
because I think that since the values are kept on the user's computer, it is possible to directly access the value of these variables. But the values of the specified keys are not returned by sessionstorage . I looked on this stackoverflow question and also on this one but nothing. Thanks!