Javascript and dynamic pages cannot obtain the cookie expiration time. The expiration time is managed by the browser. JavaScript and dynamic pages can only set the expiration time, which cannot be obtained through the document.cookie (javascript) or Cookie.Expires (asp.net) attribute. arrive.
<%@page language="C#" Debug="true"%>
Although the asp.net cookie has the Expires attribute, the Expires attribute output by Response.Write is 0001-1-1 0:00:00 (DateTime.MinValue). This is because the browser does not send the expiration of the cookie. Time is given to the server, so DateTime.MinValue is used to fill the Expires property of the cookie.
You must get the expiration time, and you need to use another cookie value to record the expiration time of the corresponding cookie. As follows:
<script><br>
var d = new Date();<br>
d.setHours(d.getHours() 1); //Expires in 1 hour<br>
Document.cookie = 'testvalue=123;expires=' d.toGMTString(); //Storage cookie value<br>
document.cookie = 'testexp=' escape(d.toLocaleString()) ';expires=' d.toGMTString(); //Storage cookie expiration time. To obtain the expiration time of the testvalue cookie, obtain the testexp cookie. <br>
<br>
</script>