zoukankan      html  css  js  c++  java
  • js 设置cookie转

    原文地址: http://www.cnblogs.com/wwcherish/archive/2013/04/17/3026848.html

    <script type="text/javascript">
            function Get_Cookie(name) {
                var start = document.cookie.indexOf(name + "=");
                var len = start + name.length + 1;
                if ((!start) && (name != document.cookie.substring(0, name.length))) return null;
                if (start == -1) return null;
                var end = document.cookie.indexOf(";", len);
                if (end == -1) end = document.cookie.length;
                return decodeURI(document.cookie.substring(len, end));
            }

            function Set_Cookie(name, value, expires, path, domain, secure) {
                expires = expires * 60 * 60 * 24 * 1000;
                var today = new Date();
                var expires_date = new Date(today.getTime() + (expires));
                var cookieString = name + "=" + decodeURIComponent(value)/** encodeURIComponent(value) 貌似也行**/ +
                     ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
                     ((path) ? ";path=" + path : "") +
                     ((domain) ? ";domain=" + domain : "") +
                     ((secure) ? ";secure" : "");
                document.cookie = cookieString;
            }

            //页面加载
            $(function () {

                Set_Cookie('dynewform_name', 'zhuname', 36500);
                var nameone = Get_Cookie("dynewform_name");
               
                 alert(nameone)  //==>zhuname
            });
        </script>

  • 相关阅读:
    luogu P3959 宝藏
    hdu4035 Maze
    [hdu2899]Strange fuction
    luogu4407 [JSOI2009]电子字典 字符串hash + hash表
    SPOJ6717 Two Paths 树形dp
    luogu4595 [COCI2011-2012#5] POPLOCAVANJE 后缀自动机
    后缀数组
    luoguP1659 [国际集训队]拉拉队排练 manacher算法
    luoguP4555 [国家集训队]最长双回文串 manacher算法
    CF17E Palisection 差分+manacher算法
  • 原文地址:https://www.cnblogs.com/ry123/p/3040904.html
Copyright © 2011-2022 走看看