index.js 708 字节
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
function cookieGet(name) {
    var strcookie = document.cookie; //获取cookie字符串
    var arrcookie = strcookie.split("; "); //分割
    //遍历匹配
    for (var i = 0; i < arrcookie.length; i++) {
        var arr = arrcookie[i].split("=");
        if (arr[0] == name) {
            return arr[1];
        }
    }
    return "";
}

// 打印所有cookie
function cookiePrint() {
    var strcookie = document.cookie; //获取cookie字符串
    var arrcookie = strcookie.split(";"); //分割

    //遍历匹配
    for (var i = 0; i < arrcookie.length; i++) {
        var arr = arrcookie[i].split("=");
        console.log(arr[0] + "" + arr[1]);
    }
}
export default { cookieGet, cookiePrint }