Save data in LocalStorage and then check if it exists on another page

0

Good afternoon person. I need to save a data in LocalStorage and then check if this value exists on another page, I tried it here but it did not 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')){

}
    
asked by anonymous 06.09.2018 / 21:43

2 answers

0

It worked when I did this:

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
            }
    
10.09.2018 / 15:53
0

Your browser is blocking access to the localStorage. To resolve this go to the browser content settings and allow third-party sites to save cookies and information. See here the path in chrome

    
06.09.2018 / 22:00