Step One: Download Library cookies
https://github.com/js-cookie/js-cookie
Step Two: Set expiration time of Cookies, there are two methods, and by the day calculated in hours
function popup () { the console.log ( "pop!" ); } // Get Cookies var User = Cookies.get ( "User" ); IF (! User) { // calculated daily expiration time of 1 day; // Cookies.set ( 'User', '998', {expires:. 1}); // hourly, expiration time of 24 hours var inFifteenMinutes = new new a Date ( new new . a Date () the getTime () + 24 * 60 60 * 1000 * ); Cookies.set ( 'User', 'to true' , { Expires: inFifteenMinutes }); // call the popup popup() } //删除Cookies // Cookies.remove("user");
Note: If the time is not set cookies, cookies default expiration time is until you close your browser, cookies fail
Step 3: Check cookie in Google Chrome