JQuery implements a summary of mandatory cookie expiration methods, jquerycookie
Method 1:
Var date = new Date (); date. setTime (date. getTime () + (x * 60*1000); $. cookie ('example ', 'foo', {expires: date });
Method 2:
<Script type = "text/javascript"> var expiresDate = new Date (); expiresDate. setTime (expire. getTime () + (? * 60*1000 ));//? Replace it with the number of minutes. If it is 60 minutes, it is 60*60*1000 $. cookie ("_ cookie _", 'helloworld', {path: '/', // cookie scope expires: expiresDate}) ;}</script>
Method 3:
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 var d = dd of the current month. getDate (); date = new Date (y + '-' + m + '-' + d + '00:00:00 '); date. setTime (date. getTime (); // tomorrow's 0:00:00 str + = "; expires =" + date. toGMTString (); document. cookie = str ;}
The above is all the content summarized in this article. I hope you will like it.