代碼
//cookie
function comm_read_cookie(name){var cookieValue = "", search = name + "=";if(document.cookie.length > 0){offset = document.cookie.indexOf(search);if (offset != -1){offset += search.length;end = document.cookie.indexOf(";", offset);if (end == -1) end = document.cookie.length;cookieValue = unescape(document.cookie.substring(offset, end));}}return cookieValue;};
function comm_set_cookie(name,value,expirehours){var expiration = new Date((new Date()).getTime() +expirehours*3600000);document.cookie = name+ "=" + value + ";expires=" + expiration.toGMTString()+";domain=www.4usky.com;path=/";}
function delCookie(name){
var expiration = new Date((new Date()).getTime()-10);
var cval=comm_read_cookie(name);
if(cval!=null) document.cookie=name+"="+cval+";path=/;expires="+expiration.toGMTString();
}
預設沒有設定path的話path就是頁面所在的目錄下, 這個cookie也只能被這個目錄和這個目錄下的子目錄的頁面所訪問。
要想全訪問就設定path=/