Js setting cookie expiration the current time minus one second is equivalent to an immediate expiration

  • 2020-03-30 03:51:26
  • 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: