Js sets the current cookie expiration time minus one second, which is equivalent to immediate expiration. The current cookie time
Function ClearCookie () {var expires = new Date (); expires. setTime (expires. getTime ()-1000); // The current time minus one second, which is equivalent to immediate expiration (can be increased or decreased) document. cookie = "appCode = '000000'''; path =/; expires =" + expires. toGMTString () + ""; // expires indicates the expiration time. If this parameter is not set, the cookie expires when the browser is disabled by default. cookie = "roleID = '000000'; path =/; expires =" + expires. toGMTString () + ""; document. cookie = "parentMenuID = '000'''; path =/; expires =" + expires. toGMTString () + ""; document. cookie = "currentMenuName = 'haha '''; path =/; expires =" + expires. toGMTString () + "";}
Path =/; indicates that the cookie is stored in the browser root directory.
As a result, four cookies (appCode, roleID, parentMenuID, and currentmenuname) are invalid.
Set cookie expiration time in js
Function SetCookie (name, value ){
Var str = name + "=" + escape (value );
Var dd = new Date ();
Dd. setDate (dd. getDate () + 1); // get tomorrow
Var y = dd. getYear ();
Var m = dd. getMonth () + 1; // obtain the date of the current month
Var d = dd. getDate ();
Date = new Date (y + '-' + m + '-' + d + '00:00:00 ');
Date. setTime (date. getTime (); // 0:00:00 tomorrow
Str + = "; expires =" + date. toGMTString ();
Document. cookie = str;
}
Invalid expiration time set for JS Cookie?
Document. cookie = "user = blue; expires" + oDate;
This sentence is changed
Document. cookie = "user = blue; expires =" + oDate;
A "=" number is missing