admin管理员组

文章数量:1126407

For how long is data stored in localStorage (as part of DOM Storage in HTML5) available? Can I set an expiration time for the data which I put into local storage?

For how long is data stored in localStorage (as part of DOM Storage in HTML5) available? Can I set an expiration time for the data which I put into local storage?

Share Improve this question edited Jul 1, 2020 at 15:41 Kerem 11.6k5 gold badges60 silver badges58 bronze badges asked Feb 24, 2010 at 15:02 user280427user280427 4,5112 gold badges17 silver badges4 bronze badges 4
  • 9 don't use localStorage if possible because is never expire automatically, there you can use sessionStorage it is more preferrable – Dharmendrasinh Chudasama Commented Oct 25, 2017 at 5:16
  • @DharmendrasinhChudasama there is a reason why both exist: they are used in different cases. Given that the OP doesn't make any distinction between them, one assumes that they know which one they want/need

    本文标签: javascriptWhen do items in HTML5 local storage expireStack Overflow