The Android phone Wechat browser localstorage has been removed inexplicably.

problem description

users need to save the information of the last login and use localstorage to record the contents of the input box, including the password, after the login is successful.
is not a complete phenomenon . Sometimes the Android phone Wechat browser localstorage is inexplicably cleared, and the whole project does not write the code to remove localstorage. Only Android phones appear, not Apple.

the environmental background of the problems and what methods you have tried

to prevent the localstorage from being cleared and causing the user to type again, I even used cookie, but the weird thing is that cookie was cleared along with localstorage.

related codes

the project uses the vue framework, not other ui frameworks.

mounted() {
     //
     let username = localStorage.getItem("username") || this.getCookie("username");
     let password = localStorage.getItem("password") || this.getCookie("password");
     if (username) {
          this.user.username = username;
     }
     if (password) {
          this.user.password = password;
     }
},
//
    localStorage.setItem("username", this.user.username);
    localStorage.setItem("password", this.user.password);
    this.setCookie("username",this.user.username)
    this.setCookie("password",this.user.password)
Jul.14,2021

the same problem has been solved


has not encountered this kind of problem, is there too much data stored in localstorage? It only has 5m space


generally speaking, this does not happen.

you confirm two points first:

  1. whether you use the phone to clear the cache or what cleaning software you use.
  2. does emptying mean that the localstorage data is gone? If so, it is recommended to rewrite the removeItem and clearItem of localStorage to avoid it, and you can also locate who called this method.
Menu