H5 sets cookie to determine the occasional failure of a part of the display page

function setCookie(key, value, expires) {
    var cookieStr = key + "=" + value;
    if (expires) {
        cookieStr += "; " + "max-age" + "=" + 1;
    }
    document.cookie = cookieStr;
}
function getCookie(sName) {
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; iPP) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    return null;
}
$(function(){
var act = getCookie("act");
    //
    if (act == "freshen") {
        $(".loader-container,.p1,.p2,.p3").addClass("none")
        swiperInit()
    }
    else {
        $(".p1,.p2,.p3,.loader-container").removeClass("none")
    }
    
     $(".btn-goLottery").on("click", function () {
        var exp = new Date();
        exp.setTime(exp.getTime() + 1000);
        exp = exp.toGMTString();
        setCookie("act", "freshen", exp);
        window.location.href = url + "/default/index"
    });
})


 

now it"s like this: I click on the lottery store cookie to jump to cookie to judge that some part of the page is hidden in the value display
, but now there will be occasional failures on the real machine, that is, refreshing the part that you don"t want to hide

.
Mar.18,2021

because you setCookie jumps immediately after, all disk operations are the same, and you don't wait for to physically write to disk .

https://codeshelper.com/q/10.


try localStorage


try, setCookie ("act" with promise, and then execute window.location.href = url +'/ default/index'


localStorage

after the "freshen", exp) is finished.
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-1e4640c-44b79.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-1e4640c-44b79.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?