亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

html5 - WeChat exits the program, storage and cookies will be lost
大家講道理
大家講道理 2017-05-31 10:41:38
0
2
1091

When WeChat exits the program, storage and cookies will be lost. How to solve the problem?

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

reply all(2)
習(xí)慣沉默

LocalStorage shouldn’t be lost, right?

劉奇

I also encountered this problem here. I don’t know whether the localstrorage is lost or there is no way to obtain it, especially when testing on the mobile phone. Anyway, it is certain that the WeChat browser has a lot of unstable performance. The solution is to use cookies.

//解決微信不定時localstrorage失效問題
//傳入cookie
var setCookie = function(c_name,value,expiredays)
{
    var exdate=new Date()
    exdate.setDate(exdate.getDate()+expiredays)
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

//取出cookie
var getCookie = function(c_name)
{
    if (document.cookie.length>0)
      {
      c_start=document.cookie.indexOf(c_name + "=")
      if (c_start!=-1)
        { 
        c_start=c_start + c_name.length+1 
        c_end=document.cookie.indexOf(";",c_start)
        if (c_end==-1) c_end=document.cookie.length
        return unescape(document.cookie.substring(c_start,c_end))
        } 
      }
    return ""
}

Of course, it mainly stores some key information, such as some constants, sessionId, loginToken, etc. If the user data is relatively large, I still use localstrorage. I just request the data again when needed, save and retrieve again.
The method used is rather clumsy, I hope it can help you, and I also hope that someone who can’t see it can give me some advice~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template