• js读写cookie


    <div id="link"></div>
    <script>
    function SetCookie(cookieName, cookieValue, path, domain, secure){
     var expires = new Date();
     expires.setTime(expires.getTime() + 9000000000);
     document.cookie = escape(cookieName) + '=' + escape(cookieValue)
     + (expires ? '; expires=' + expires.toGMTString() : '')
     + (path ? '; path=' + path : '/')
     + (domain ? '; domain=' + domain : '')
     + (secure ? '; secure' : '');
    }
    function GetCookie(name){ 
     var cookie_start = document.cookie.indexOf(name);
     var cookie_end = document.cookie.indexOf(";", cookie_start);
     return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
    } 
    function DelCookie(cookieName, cookieValue, path, domain, secure){ 
     var cookieValue="hello";
     var expires = new Date();
     expires.setTime(expires.getTime() - 100000);
     document.cookie = escape(cookieName) + '=' + escape(cookieValue)
     + (expires ? '; expires=' + expires.toGMTString() : '')
     + (path ? '; path=' + path : '/')
     + (domain ? '; domain=' + domain : '')
     + (secure ? '; secure' : '');
    } 
    
    //创建,或是修改cookie
    
    SetCookie("name","123");
    SetCookie("site","fsdf");
    
    //读取cookie
    
    GetCookie("name");
    
    //作为超级链接
    document.getElementById("link").innerHTML="http://xxx.com/?name="+GetCookie("name");
    </script>
    提问者评价

    参考至: http://zhidao.baidu.com/link?url=fRS5Pa05JGP2LgKwVkcLtYyvQxRoSx9iq6LsyUbFkdlSIXR8VN3yHMCbyKO7CNSvYQEFDxpfszbm_n9G4XlRh_

  • 相关阅读:
    jQuery-选择器及属性修改
    jQuery 基础理论
    CSS 之 BFC(块级格式化上下文)
    H5--Web Storage
    H5 -WebWorker
    H5 --拖放
    nodejs Multer中间件
    k8s pod
    kubernetes
    优化CUDA数据传输
  • 原文地址:https://www.cnblogs.com/yudishow/p/4288421.html
Copyright © 2020-2023  润新知