• JS写Cookie



            function writeCookie() {
                var today = new Date();
                today.setDate(today.getDate() + 1);
                document.cookie = 'userName=商商;Expires=' + today.toGMTString();//js进行设置过期时间时,只支持这种日期转码
            }

            function readyCookie() {


                var cookie = document.cookie;
                alert(cookie);
                var array = cookie.split(';');
                for (var item in array)
                {
                    var array1 = array[item].split('=');
                    for (var item1 in array1)
                    {
                        if (array1[item1] = 'userName')
                        {
                          // alert(array1[item1]);
                           alert(array1[0]);
                          //return;
                        }
                    }
                }
            }

        </script>

    </head>
    <body>
        <input id="Button1" type="button" value="写入Cookie" onclick="writeCookie()" />
        <input id="Button2" type="button" value="读出Cookie" onclick="readyCookie()" />
    </body>
    </html>

  • 相关阅读:
    收藏的 30 个CSS 代码段
    Power designer 15生成sql server 2005/2008列注释
    华为网盘
    敏捷宣言(一)
    敏捷宣言(三) Scrum是一种敏捷实践
    敏捷宣言(二) 何为敏捷
    我也曾哭过[转]
    你以为我穷,不好看,就没有感情吗?[转]
    关于异性朋友
    Gone With the Wind[转]
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3024946.html
Copyright © 2020-2023  润新知