0
Good afternoon person. I need to save a data in Localstorage and then check if this value exists on another page, I tried here but it didn’t work.
First I define the value of the "variable" Prof_amc
if($(myEmail == singleMail)){
if(approved == true && categoria == 'PLF'){
// Cria um item "Prof_AMC" com o e-mail do usuário
window.localStorage.setItem('Prof_AMC', singleMail);
window.location.href = document.referrer+'?sc=2'; // Parametro URL Politica PLF
}
Then on another page I try to check if it exists and if the SC parameter is different from -1:
if(window.location.href.indexOf("sc")!=-1 && localStorage.getItem('Prof_AMC')){
}
vc gave a console.log in this result localStorage.getItem('Prof_amc') to check what’s coming?
– Ademilson Santana da Silva
Type localStorage.getItem('Prof_amc') in Chrome console? If it is an error Uncaught Domexception: Failed to read the 'localStorage' Property from 'Window': Access is denied for this Document. at <Anonymous>:1:1
– Frederico Moreira
The two pages that access Localstorage are on the same domain or is a redirect external?
– fernandosavio
tried in another browser?
– Ademilson Santana da Silva
same domain, it was my mistake here so I wasn’t giving. I tried now and the result was null, IE, is not passing the variable to localStorage
– Frederico Moreira
I also tried in firefox and tbm gave null it seems that is not passing anything from one page to another
– Frederico Moreira
try the solution I posted there, if it doesn’t work, go in your code and right after you give setItem in localStorage, use the js console.log(localStorage) command and see if you’re saving
– Ademilson Santana da Silva