提取cookie中的值

//提取cookie中的值

CloudShareCommon.prototype.getCookie = function (name) {
    var cookieStr = document.cookie;
    if (cookieStr.length > 0) {
        var cookieArr = cookieStr.split(";"); //将cookie信息转换成数组
        for (var i = 0; i < cookieArr.length; i++) {
            var cookieVal = cookieArr[i].split("="); //将每一组cookie(cookie名和值)也转换成数组
            if (cookieVal[0] == name) {
                return unescape(cookieVal[1]); //返回需要提取的cookie值
            }
        }
    }
}

 

转载于:https://www.cnblogs.com/queende7/p/8669037.html

    原文作者:abc20140818
    原文地址: https://blog.csdn.net/abc20140818/article/details/101410746
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞