JavaScript之setcookie()讲解

function setcookie(name,value){  
        var Days = 30;  
        var exp  = new Date();  
        exp.setTime(exp.getTime() + Days*24*60*60*1000);  
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();  
    }  
     

    function getcookie(name){  
        var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));  
        if(arr != null){  
            return (arr[2]);  
        }else{  
            return "";  
        }  
    }  
     

    function delcookie(name){  
        var exp = new Date();  
        exp.setTime(exp.getTime() - 1);  
        var cval=getCookie(name);  
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();  
    }  
     

    //delcookie("GD-cms");  

    if (document.cookie != "") {  
        setcookie("GD-cms", "gae-django-cms");  
    }  
    alert(getcookie("GD-cms")); 

JavaScript之setcookie()讲解,布布扣,bubuko.com

JavaScript之setcookie()讲解

上一篇:重拾python mac1.9.2


下一篇:python通过ip获取地址