function Cookie(name){
        this.$name  = name;    
        var allcookies = document.cookie;
        if(allcookies == "")return;
        var cookies = allcookies.split(";");
        var cookie = null;
        for(var i = 0; i < cookies.length; i++){
            //    Does this cookie string begin with the name we want?
            if (cookies[i].substring(0, name.length+1) == (name + "=")){
                cookie = cookies[i];
                break;
            }
        }
        if (cookie == null) return;
        var cookieval = cookie.substring(name.length+1);
        var a = cookieval.split("&");
        for(var i=0; i < a.length; i++){
            a[i] = a[i].split(":");
        }
        for(var i=0; i < a.length; i++){
            this[a[i][0]] = decodeURIComponent(a[i][1]);
        }
    }
/**
*    This function is the store() method of the Cookie object.
*
*    Arguments:
*
*    daysToLive: the lifetime of the cookie, in days. If you set this
*      to zero, the cookie will be deleted. If you set it to null, or
*      omit this argument, the cookie will be a session cookie and will
*      not be retained when the browser exits. This argument is used to
*      set the max-age attribute of the cookie.
*    path: the value of the path attribute of the cookie
*    domain: the value of the domain attribute of the cookie
*    secure: if true, the secure attribute of the cookie will be set
*/    
    Cookie.prototype.store = function(daysToLive, path, domain, secure){
        var cookieval = "";
        for(var prop in this){
            if ((prop.charAt(0) == "$") || ((typeof this[prop]) == "function"))
                continue;
            if (cookieval != "") cookieval += "&";
            cookieval += prop + ":" + encodeURIComponent(this[prop]);
        }
        var cookie  = this.$name + "=" + cookieval;
        if (daysToLive || daysToLive == 0){
            cookie += "; max-age=" + (daysToLive*24*60*60);
        }
        if (path) cookie += "; path=" + path;
        if (domain) cookie += "; domain=" + domain;
        if (secure) cookie += "; secure";
        
        document.cookie = cookie;
    };
    
/**
*    This function is the remove() method of the Cookie object; it deletes the
*    properties of the object and removes the cookie from the browser's
*    local store.
*
*    The arguments to this function are all optional, but to remove a cookie
*    you must pass the same value you passed to store().
*/
    Cookie.prototype.remove = function(path,domain, secure){
        for(var prop in this){
            if (prop.charAt(0) != "$" && typeof this[prop] != "function")
                delete this[prop];
        }
        this.store(0,path,domain,secure);
    };
    
/**
*    This static method attempts to determine whether cookies are enabled.
*    It returns true if they appear to be enabled and false otherwise.
*    A return value of true does not guarantee that cookies actually persist    .
*    Nonpersistent session cookies may still work even if this method
*    return false.
*/
    Cookie.enabled = function(){
        if (navigator.cookieEnabled != undefined) return navigator.cookieEnabled;
        if (Cookie.enabled.cache != undefined) return Cookie.enabled.cache;
        document.cookie = "testcookie=test; max-age=10000";
        var cookies = document.cookie;
        if (cookies.indexOf("testcookie=test") == -1){
            return Cookie.enable.cache = false;
        }
        else{
            document.cookie = "testcookie=test; max-age=0";
            return Cookie.enable.cache = true;
        }
    };上面是从js权威指南上摘抄下来的代码按照代码 , 我是这样操作的cookie  var cookie=new Cookie('docman');  
 cookie.close=1;
 cookie.store(1,"/");这样的话  我只要在同意域名下,就能读取到这个cookie,但是  我只要离开设置cookie的页面就读取不到了 求解 , 我用的是火狐和google的浏览器 。。
可能是我水平实在有限
望高人指教