zoukankan      html  css  js  c++  java
  • cookie.js

    String.prototype.Trim = function(){
    return this.replace(/^s+/g,"").replace(/s+$/g,"");
    }

    function JSCookie(){
    this.GetCookie = function(key){
    var cookie = document.cookie;
    alert(cookie);
    var cookieArray = cookie.split(';');
    var getvalue = "";
    for(var i = 0;i<cookieArray.length;i++){
    if(cookieArray[i].Trim().substr(0,key.length) == key){
    getvalue = cookieArray[i].Trim().substr(key.length + 1);
    break;
    }
    }
    return getvalue;
    };
    this.GetChild = function(cookiekey,childkey){
    var child = this.GetCookie(cookiekey);
    var childs = child.split('&');
    var getvalue = "";
    for(var i = 0;i < childs.length;i++){
    if(childs[i].Trim().substr(0,childkey.length) == childkey){
    getvalue = childs[i].Trim().substr(childkey.length + 1);
    break;
    }
    }
    return getvalue;
    };
    this.SetCookie = function(key,value,expire,domain,path){

    if(path==null){
    path = "/";
    }


    var cookie = "";
    if(key != null && value != null)
    cookie += key + "=" + value + ";";
    if(expire != null)
    cookie += "expires=" + expire.toGMTString() + ";";
    if(domain != null)
    cookie += "domain=" + domain + ";";
    if(path != null)
    cookie += "path=" + path + ";";
    document.cookie = cookie;
    };
    this.Expire = function(key){
    expire_time = new Date();
    expire_time.setFullYear(expire_time.getFullYear() - 1);
    var cookie = " " + key + "=e;expires=" + expire_time + ";"
    document.cookie = cookie;
    }
    }

  • 相关阅读:
    re模块
    正则表达式
    python-函数基础(*arge **kwargs)
    Python-类基础
    Python内置函数
    有些事情自己知道就好
    jquery和dom之间的转换
    Jquery中attr和prop的区别
    thinkphp一对多HAS_MANY
    thinkphp表单自动验证
  • 原文地址:https://www.cnblogs.com/zhu-java/p/4564732.html
Copyright © 2011-2022 走看看