zoukankan      html  css  js  c++  java
  • js 获取读取cookie

    // --- 设置cookie
    function setCookie(sName, sValue, expireHours) {
        var cookieString = sName + "=" + escape(sValue);
        //;推断是否设置过期时间
        if (expireHours > 0) {
            var date = new Date();
            date.setTime(date.getTime + expireHours * 3600 * 1000);
            cookieString = cookieString + "; expire=" + date.toGMTString();
        }
        document.cookie = cookieString;
    }

    //--- 获取cookie
    function getCookie(sName) {
        var aCookie = document.cookie.split("; ");
        for (var j = 0; j < aCookie.length; j++) {
            var aCrumb = aCookie[j].split("=");
            if (escape(sName) == aCrumb[0])
                return unescape(aCrumb[1]);
        }
        return null;
    }

  • 相关阅读:
    hsdis反汇编java源码工具的使用方法
    final添加内存屏障问题
    Spring-AOP
    Spring-IOC
    IO与NIO
    设计模式学习笔记
    Redis学习笔记
    MySQL优化
    STAR法则
    大文件分割之Linux
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/6707382.html
Copyright © 2011-2022 走看看