Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
how to remove localstorage in javascript after some time

I have 5 stages on the signup page so I used the user id to check the user stage by storing his id in local storage. I want to remove the id from localstorage when users leave my website without filling the form. I want to remove local storage after some time.

Is it possible to remove items from local storage when the user is not on my website?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use session or cookie storage for that purpose, but if you want to use local storage then you can use onunload or onbeforeunload event listeners of JS and clear local storage on onunload. These listeners work perfectly on tab close or tab back button as well.

about 4 years ago · Juan Pablo Isaza Relatório

0

As Estus Flask and Samuel Liew also suggested to use sessionStorage as per the requirement you have. But still if you want to use localStorage for any reasons. You can use :

localStorage.removeItem(<your item comes here>)

Called this inside beforeDestroy() hook as it called right before a vue instance destroy.

This will ensure that before the instance is removed from the DOM, we are removing an item from the localStorage.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda