//清除用户cookie

function loingout() {


    //        var date = new Date();


    //        date.setTime(date.getTime() - 1);


    //            document.cookie = "LoginName" + "=; expires=" + date.toGMTString();


    //        var name="LoginName";


    //        var exp = new Date();


    //        exp.setTime(exp.getTime() - 1);


    //        var cval=GetAsaiCookie(name);


    //        document.cookie = name + "=null;expires=" + exp.toGMTString();


    //        //window.location.href = "/index.html";


    //        var cval = GetAsaiCookie(name);


    //        alert(cval);


    deleteCookie("LoginName");


    window.location.href = "/index.html";


}


//设置cookie


function setCookie(name, value, option) {


    //用于存储赋值给document.cookie的cookie格式字符串


    var str = name + "=" + escape(value);


    if (option) {


        //如果设置了过期时间


        if (option.expireDays) {


            var date = new Date();


            var ms = option.expireDays * 24 * 3600 * 1000;


            date.setTime(date.getTime() + ms);


            str += "; expires=" + date.toGMTString()+

";path=/"

;


        }


        if (option.path) str += "; path=" + path;   //设置访问路径


        if (option.domain) str += "; domain" + domain; //设置访问主机


        if (option.secure) str += "; true";    //设置安全性


    }


    document.cookie = str;


}


//删除cookie


function deleteCookie(name) {


    this.setCookie(name, "", { expireDays: -1 }); //将过期时间设置为过去来删除一个cookie


}


//读取cookies


function GetAsaiCookie(name) {


    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");


    if (arr = document.cookie.match(reg)) return unescape(arr[2]);


    else return null;


}



我最还是的路径是http://localhost:8746/index.html,然后下面这个路径就不能正常的使用了,http: //localhost:8746/users/mymanage/mymanagebaseinfo.html,当时找原因就找了半天,有关 cookie的各个属性全看完,其中在http://www.cftea.com/c/825.asp这里找到了一点思路,然后恍然大雾,原来是设置的路 径问题。文中红色区域表示。呵呵 最后问题解决..收工 .哈哈