js cookie函数

admin4年前javascript553
///设置cookie
function setCookie(NameOfCookie, value, expiredays) {
    var ExpireDate = new Date();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}
///获取cookie值
function getCookie(NameOfCookie) {
    if (document.cookie.length > 0) {
        begin = document.cookie.indexOf(NameOfCookie + "=");
        if (begin != -1) {
            begin += NameOfCookie.length + 1;
            end = document.cookie.indexOf(";", begin);
            if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
        }
    }
    return null;
}
///删除cookie
function delCookie(NameOfCookie) {
    if (getCookie(NameOfCookie)) {
        document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/";
    }
}


相关文章

阿里oss压缩图片和获取视频第一帧简便方法

OSS获取视频第一帧方法: 视频地址+?x-oss-process=video/snapshot,t_1000,m_fast 例:https://video.aliyunoss.com/1.mp4?x...

paypal网站集成指南

原文链接:https://blog.csdn.net/wcjzff/article/details/81237551...

laydate使用

laydate.render({         elem: '#dateinput',&n...

viewjs使用参考

https://www.jq22.com/jquery-info6536{eyou:static file="/public/plugins/viewerjs/css/viewer.min....

swiper + 文字特效

swiper + 文字特效

swiper.animate1.0.3.min-1.ziphttps://blog.csdn.net/huayuaer/article/details/101761316...

animate.css动画案例

https://animate.style/...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。