获取cookie 指定值

审核中 JavaScript 未结 已结 置顶 精帖
删除 置顶 取消置顶 加精 取消加精
66 0
yswl
yswl VIP3 2023-04-24 15:49:11
悬赏:60金币 编辑此贴

获取 cookie 指定值

function getCookie(cookieName) {
      const strCookie = [xss_clean]
      const cookieList = strCookie.split(';')
      
      for(let i = 0; i < cookieList.length; i++) {
        const arr = cookieList[i].split('=')
        if (cookieName === arr[0].trim()) {
          return arr[1]
        }
      }
      
      return ''
    }
    
    var weblan_val = getCookie("weblan");