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.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eafc3d-48054.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eafc3d-48054.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?