function getCookieValue(name) {
let result = document.cookie.match("(^|[^;]+)\\s*" + name + "\\s*=\\s*([^;]+)")
return result ? result.pop() : ""
}
function getCookie(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 ""
}
本文提供了两种JavaScript函数用于从浏览器中读取Cookie的值。通过使用这些函数,开发者可以轻松地访问和利用存储在用户浏览器中的Cookie信息。
1万+

被折叠的 条评论
为什么被折叠?



