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>

  • 相关阅读:
    spark 安装
    maven 常用配置
    矩阵SVD在机器学习中的应用
    机器学习—单变量线性回归
    Stanford机器学习
    Memcached 安装和客户端配置
    Lucene 学习之二:数值类型的索引和范围查询分析
    Go-errors第三方包学习
    Go日志库使用-logrus
    Go语言---小白入门-命令行库Cobra的使用
  • 原文地址:https://www.cnblogs.com/ry123/p/3040904.html
Copyright © 2011-2022 走看看