zoukankan      html  css  js  c++  java
  • js操作cookie

    function set_cookie(key, value, exp, path, domain, secure) {
            path = "/";
            var cookie_string = key + "=" + escape(value);
            if (exp) {
                cookie_string += "; expires=" + exp.toGMTString();
            }
            if (path)
                cookie_string += "; path=" + escape(path);
            if (domain)
                cookie_string += "; domain=" + escape(domain);
            if (secure)
                cookie_string += "; secure";
            document.cookie = cookie_string;
        }
    
        /*读取 cookie*/
        function get_cookie(cookie_name) {
            var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
            if (results)
                return (unescape(results[2]));
            else
                return null;
        }
    
        /*删除 cookie*/
        function del_cookie(cookie_name) {
            var cookie_date = new Date();
            //current date & time
            cookie_date.setTime(cookie_date.getTime() - 1);
            document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
        }
  • 相关阅读:
    Linux文件查询笔记
    C语言学习和回顾
    hive的数据压缩
    进程线程那些事儿
    hive的数据存储格式
    hive的内置函数
    Hive自定义函数
    spark编译
    Impala的安装和使用
    数据库的读写分离
  • 原文地址:https://www.cnblogs.com/ethy/p/4972210.html
Copyright © 2011-2022 走看看