Browse Source

feat: 添加Cookie检查逻辑以验证用户登录状态

lsc 1 day ago
parent
commit
667c61751b
1 changed files with 11 additions and 0 deletions
  1. 11 0
      js/liyuan/Onload2.js

+ 11 - 0
js/liyuan/Onload2.js

@@ -331,6 +331,7 @@ U.MD.D.error = function (errorMessage, scripturi, linenumber, columnnumber, erro
  */
 let LoginState = false
 let CookieS = ''
+let CookieCheckTimes = 0
 U.MD.D.getuser = function () {
     // $("#U_MD_D_BG")[0].style.backgroundImage = 'url("/img/icon/gif/longhuaBg.gif")'
     var userInfo = US.userInfo;
@@ -719,6 +720,16 @@ U.MD.D.getuser = function () {
                 window.location.reload();
             }
         }, [], { "type": "GET", "withCredentials": true });
+    }else if(LoginState && _cookie){
+        CookieCheckTimes++
+        if (CookieCheckTimes % 5 !== 0) return;
+        U.A.Request(US.Config.server + "getcookieuserid", [], function (res) {
+            if (res.value && res.value[0] && res.value[0][0]) {
+            }else {
+                window.onbeforeunload = null
+                window.location.reload();
+            }
+        }, [], { "type": "GET", "withCredentials": true });
     }
 }