How to use session to prevent a modal from opening again?

2

I have a site in HTML, in the index I put a modal to open as soon as the person enters, this modal is to collect the person's email, however every time the person updates the site the modal reappears . I would like to know if you have something to do with using javascript where it opens only once, then it appears again only if the user closes the browser and back.

    
asked by anonymous 17.03.2016 / 16:19

1 answer

3

Yes you can use sessionStorage ;

The logic would be this, before the modal open you ask:

 // É diferente de true?  <- nunca abriu?
if(!sessionStorage.getItem("abriu")){
   // Abra a modal
   sessionStorage.setItem("abriu",true); // na próxima vez ela não entrara na condição.
}
    
17.03.2016 / 16:54