function ClearCookie() { var expires = new Date(); expires.setTime(expires.getTime() - 1000); //當前時間減去一秒,相當於立即過期(可以增減) document.cookie = "appCode='222''';path=/;expires=" + expires.toGMTString() + ""; //expires是對應過期時間的設置,不設這個值,cookie默認在關閉浏覽器時失效 document.cookie = "roleID='333''';path=/;expires=" + expires.toGMTString() + ""; document.cookie = "parentMenuID='000''';path=/;expires=" + expires.toGMTString() + ""; document.cookie = "currentMenuName='哈哈''';path=/;expires=" + expires.toGMTString() + ""; }
path=/;表示cookie存放的位置是浏覽器根目錄
上述方法導致appCode,roleID,parentMenuID,currentMenuName4個cookie失效