life cycle expires cookie time expired, but have not been cleaned browser cookie problem

life cycle expires cookie time expired, but have not been cleaned browser cookie problem

Nodejs played today with a web service, using art-template template engine render the page where I set a cookie, set the expiration time to 10 seconds after the code is as follows:

var t = new Date();
var day = t.getSeconds() + 10;
t.setSeconds(day);
// time to failure is converted into a string
was TSTR = t.toString ();
if (document.cookie.length <= 0) {
     document.cookie = 'name=小明; expires=' + tStr;
}
 
But 10 seconds after the last cookie has not expired, you can also get to find for a long time had rendered the service side of the page, the cookie expiration time the comparison is made according to the time server
Server time:

 

Client time:

So the time to failure by services from time to set up, cookie can successfully fail, the browser is cleared.

Here the server time, I was in the print server.

 

Guess you like

Origin www.cnblogs.com/liangziaha/p/11249664.html