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>

  • 相关阅读:
    iOS 109个Demo范例
    iOS 109个Demo范例
    iOS 完全复制UIView
    iOS 完全复制UIView
    iOS 获取self类型
    Python 进阶_OOP 面向对象编程_类和继承
    Python 进阶_OOP 面向对象编程_类和继承
    Python 进阶_模块 & 包
    Python 进阶_模块 & 包
    Python 进阶_模块 & 包
  • 原文地址:https://www.cnblogs.com/ry123/p/3040904.html
Copyright © 2011-2022 走看看