发布于 5年前

cookie字符串中获取token

function getTokenByCookie(cookies_str) {
  if (!cookies_str) return null
  let cookies = cookies_str.split(';')
  for (let i = 0; i < cookies.length; i++) {
    let cookie = cookies[i].trim().split('=')
    if (cookie[0] == 'token') {
      return cookie[1]
    }
  }
  return null
}
©2020 edoou.com   京ICP备16001874号-3