Js读写Cookie
// 读取cookie
function getCookie(key) {
if (document.cookie.length > 0) {
var start = document.cookie.indexOf(key + "=")
if (start !== -1) {
start = start + key.length + 1
var end = document.cookie.indexOf(";", start)
if (end === -1)
end = document.cookie.length
return unescape(document.cookie.substring(start, end))
}
}
}
// 设置cookie
function setCookie(key, value, second) {
var cookie = key + "=" + escape(value) + ";";
if (second !== undefined && second !== '') {
cookie += "Max-Age=" + second + ";";
}
document.cookie = cookie
}如果咩咩的文章对你有帮助,您可以 请我喝牛奶
郑羊羊咩的窝
现在很多站都http only了...?