Js sets the cookie expiration and clears the cookie with the corresponding name of the browser

  • 2020-03-26 21:38:53
  • OfStack

 
function ClearCookie() { 
var expires = new Date(); 
expires.setTime(expires.getTime() - 1000); //Current time minus one second is equivalent to immediate expiration (can be added or subtracted)
document.cookie = "appCode='222''';path=/;expires=" + expires.toGMTString() + ""; //Expires is a set that corresponds to an expiration time. The cookie expires by default when the browser is closed
document.cookie = "roleID='333''';path=/;expires=" + expires.toGMTString() + ""; 
document.cookie = "parentMenuID='000''';path=/;expires=" + expires.toGMTString() + ""; 
document.cookie = "currentMenuName=' Ha ha ''';path=/;expires=" + expires.toGMTString() + ""; 
} 

Path = /; The location of the cookie is the browser root directory

The above methods lead to appCode, roleID, parentMenuID, currentMenuName4 a cookie expires

Related articles: